Transfer source files from local machine to Jenkins slave

4.1k views Asked by At

apologies for the dumb question, I'm totally new to Jenkins and trying to hack together a POC. I'm basically getting a postman collection, run via Newman to hopefully execute on Jenkins. The Jenkins setup already exists, I can create a configuration and have it installing Newman but I'm sure my permissions will be limited.

Unfortunately the Postman collection I want to work with is NOT in source control, we do not have sufficient access rights to put this where it should be, therefore I want to copy this collection, which is just a bunch of JSON files to the slave, Newman could then target these and run them.

Could anyone guide me on how to do this? I've viewed a lot of existing questions around plugins but I'm afraid I cannot install new ones and I'm not even sure what exists on our Jenkins setup. Any solutions without the need for this would be ideal. I have ticked the 'Send files or execute commands over SSH before the build starts' checkbox but seems this is only for working with the workspace, I need to get the files there first somehow

2

There are 2 answers

3
Steven Scott On BEST ANSWER

I use the Copy to Slave Plugin to copy files from the local directory on the Jenkins master into the slave's workspace directory when running each task. We maintain the files in Git and extract them with another job to the Jenkins Master, but as you are not maintaining files there, just having them on the master will work.

Then I configure the job to Copy files into Job workspace in the Build Environment settings. This will copy the files over each time the job is launched. This also works with multiple node configurations as we run the testing jobs on multiple slaves concurrently.

1
Ashish Kamat On

In case of linux slave, after doing configuration (inside Manage Jenkins->Manage nodes >new mode) there is an option called remote root directory and by selecting launch method as where you need give credentials

Once you have connected to a slave machine, your job workspace will automatically get created on a slave machine on remote root directory and code inside that will get copied through ssh tunnel (internally jenkins doing scp to slave via Java Web socket API).