简体   繁体   中英

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. The flow of test is as follows. Step 1- It generates a file and stores it in project workspace. File is getting stored on Jenkins workspace on master node(Linux). Step 2 - On slave (Windows), script is opening application and browser upload window to upload the file which is stored in Jenkins workspace. Step 3 - AutoIt is used to automate the 'File uploading' part. 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. Because it will accept only file path format of windows operating system.

Tried option - 1. Tried to use 'Copy to save' plugin, but it copies file at the end of the build. 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. eg "C:\\temp" is created as a directory on linux. 3. Opened jenkins on Windows node and triggered the scipt from there. 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.

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? Q2 - Is there any control mechanism, that file can be stored outside jenkins workspace?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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