How I can copy files from one remote workspace to master machine in jenkins pipeline? - jenkins

I have created one jenkins pipeline in which I am running 4 jobs on four slave machine, it creates four workspaces on all 4 slave machines ,once the execution will be completed ,I want to copy some files from the slave workspaces to master workspace or master machine .
Please help me to figure out the solution for the same.

Use the SSH Pipeline steps and use the command sshGet.
Here's the code:
sshGet remote: remote, from: "${yourSlaveFilePath}", into: "${yourJenkinsworkspaceFileName}"

Related

The pipeline script written to tranfer the pipeline project from Slave to Master in Jenkins?Master(Windows server) and Slave(windows local)

In Jenkins, I have build a pipeline project on Master and given Agent label Slave in the script where the project is build. I want to transfer this build from Slave to Master. I am not able to find the script to transfer this process as i am using Windows for both master and slave.My Master is on Windows server(i.e. VM) and Slave is on Local Windows machine.Can someone please help me to find this as I am new for the Jenkins.

Run a windows batch job on jenkins slave

I am a newbie to the jenkins and trying to run a windows batch job in Jenkins slave. I can see the workspace with all the svn code in job but when am trying to access the command from the workspace folder , i am getting an error path not specified. this is because the Jenkins master is having workspace path as [workspace]/[jobname] where as in slave it is [jobname]/[workspace]. How can i identify the workspace path in jenkins master and run from the slave . please help!
Your not supposed to work on the master. You need to tell which slave your working on with the agent{ label 's1'} block. After, go see the Snippet Generator and check the Checkout function for your svn request.

View jenkins workspace on slave

We're running tests and producing build files on a jenkins master and a jenkins slave for extra parallellisation, our RCPTT tests takes ages.
Our problem is that Jenkins -> -> Show workspace only shows the workspace on the master, so we have no way to get the builds except copying files manually over ssh.
We don't want duplication since different patches run either on master or slave, and we want to be able to get the files from both master and slave nodes.
You can use "Copy To Slave Plugin" to copy any files from master to slave.
If you use the Jenkins pipeline plugin https://jenkins.io/doc/book/pipeline/
then you can use stash / unstash:
https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-stash-code-stash-some-files-to-be-used-later-in-the-build
Her an example: https://www.cloudbees.com/blog/parallelism-and-distributed-builds-jenkins

Jenkins Slave build locations

I have just added a slave to my Jenkins build - with the idea that I can now deploy artefacts to either my dev server or my test server.
However i've now hit a problem.
When I deploy a job on the master slave, the job build directory is
$JENKINS_HOME/localmoduledirectory (as defined in the build job)
However when I deploy my job via the slave the build directory is different which breaks my jobs. The build directory is
$JENKINS_HOME/workspace/build job title/localmoduledirectory
I know I can change the workspace root directory location for the master under configure settings /advances .. so can change it to $JENKINS_HOME/workspace, but I want to stop the slave using the build job title in the path.
The end result I'm after is to have jenkins, building / deploying from the same location on two servers i.e /opt/jenkins/workspace/localmoduledirectory.
Any ideas ?
ok after lots of head scratching ...
managed to discover that the mvn plugin has a custom workspace option hidden under advanced. so configured all jobs with a customer workspace of /opt/jenkins.

Build a project remotely but pick the code from local machine through Jenkins

I'm running jenkins on my local machine. I need to build and run a project on remote machine as a slave.
I have my project(Java code) in my local machine where the Jenkins is running. So Now when I build the project it looks for the code in my slave machine and says it's not able to find the build.xml in my slave machine.
I want to be able to have Jenkins looks for the code in my local machine and build it in my slave machine and run in the slave machine.
Is that possible? if yes pls help me.
You do not state which version control system you are using? Jenkins has version control plugins for Git, Subversion, etc...
The idea is that you commit and push your changes to your source code repository and the Jenkins slave will automatically pull down the code and compile if anything has changed.
Try the copy artifact plugin. You can create 2 jobs - 1st one to just check out the source code from your repo/version control/workspace. The second job (which runs on the slave restrict where this job can be run inside the job config) can copy those files automatically to the ...remote slave/workspace and then you do whatever you want with them.
This will do what you want, but as Mark O'Çonnor mentions, the idea is you commit the changes to your repository and then the other machine checks it out.

Resources