简体   繁体   English

需要通过jenkins slave(Windows)上的浏览器窗口上传文件,但文件位于jenkins master(linux)上

[英]Need to upload file through browser window on jenkins slave (Windows) but file is on jenkins master (linux)

Jenkins master - Linux Jenkins Slave - Windows Jenkins triggers a selenium script that runs on Windows slave and perform required test. Jenkins主服务器-Linux Jenkins从服务器-Windows Jenkins触发一个在Windows从属服务器上运行并执行所需测试的硒脚本。 The flow of test is as follows. 测试流程如下。 Step 1- It generates a file and stores it in project workspace. 步骤1-生成一个文件并将其存储在项目工作区中。 File is getting stored on Jenkins workspace on master node(Linux). 文件正在存储在主节点(Linux)上的Jenkins工作空间中。 Step 2 - On slave (Windows), script is opening application and browser upload window to upload the file which is stored in Jenkins workspace. 步骤2-在从属服务器(Windows)上,脚本正在打开应用程序和浏览器上载窗口,以上载存储在Jenkins工作区中的文件。 Step 3 - AutoIt is used to automate the 'File uploading' part. 第3步-AutoIt用于自动执行“文件上传”部分。 which enters the filepath in upload window. 在上载窗口中输入文件路径。 Step 4 - Now, when trying to get the file which is on jenkins master, file path is coming as linux path which is not working on browser upload window. 步骤4-现在,当尝试获取jenkins master上的文件时,文件路径作为Linux路径出现,在浏览器上载窗口中不起作用。 Because it will accept only file path format of windows operating system. 因为它将仅接受Windows操作系统的文件路径格式。

Tried option - 1. Tried to use 'Copy to save' plugin, but it copies file at the end of the build. 尝试选项-1.尝试使用“复制以保存”插件,但它在构建结束时复制文件。 But requirement is that it has to get file and upload it at run time. 但是要求是它必须获取文件并在运行时上载它。 2. Tried to create a folder/file giving windows path to see, if it creates that folder or file on Windows, but it is creating on Jenkins master only. 2.尝试创建一个文件夹/文件,以提供Windows路径,以查看是否在Windows上创建了该文件夹或文件,但仅在Jenkins master上创建。 eg "C:\\temp" is created as a directory on linux. 例如,“ C:\\ temp”被创建为Linux上的目录。 3. Opened jenkins on Windows node and triggered the scipt from there. 3.在Windows节点上打开jenkins,然后从那里触发scipt。 No impact. 没有影响。 4. Thought of using Winscp script to transfer file from linux to windows, but it will be of no use if not able to access folder/file of slave(window OS) though code at run time which is the case as of now. 4.想到了使用Winscp脚本将文件从linux传输到Windows,但是如果无法通过运行时的代码访问从属(窗口OS)的文件夹/文件,则将是没有用的,这是目前的情况。

Q1 - Is there any way, we can access slave's folder/file memory to save/get file at run time though script is triggered through Jenkins master? Q1-有什么办法,尽管脚本是通过Jenkins master触发的,我们还是可以在运行时访问slave的文件夹/文件内存来保存/获取文件吗? Q2 - Is there any control mechanism, that file can be stored outside jenkins workspace? 问题2-是否有任何控制机制可以将该文件存储在jenkins工作区之外?

you can try pipeline build like below: 您可以尝试如下构建管道:

pipeline{
    agent { label 'master' }
    stages {
        stage('Some Stage') {
            steps{
                    // This will create temporary zip of files for current build from master
                  stash includes: 'your/folder/path/pattern', name : 'tempName'
              }
            }            
        stage('Run node server') {
            agent { label 'slave name' }
            steps{
                // unzip the files which are zipped previously
                    unstash 'tempName'
                }
            }
    }
}

Note the agent at each stage the label will be the agent label which you have setup already. 请注意,在每个阶段,座席标签将是您已经设置的座席标签。

Refer this doc for more info 请参阅文档以获取更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM