Copy files from slave to master in Jenkins? - jenkins

Copy to slave plugin using Here running slave and copying file *.app from slave to master. so In Post build action selected an option to Copy files back to the job's workspace on the master node. Now, in Option files to copy added .app but files are not been copied.
Logs are printed as below :
[copy-to-slave] Copying '.app', excluding nothing, from 'file:/C:/JenkinsSlave/workspace/abc/PLATFORM/iOS/' on 'hudson.slaves.DumbSlave[ slave]' to 'file:/mnt/jenkins/builds/workspace/abc/' on the master.
so on above path file are not being copied. Any suggestion and solutions are welcomed. Thanks
Under Jenkins write the actions as below:
Post Build Action
Copy files back to the job's workspace on the master node
Files to copy - **/.app

Related

adding file to jenkins pipeline build folder after cloning repository but before tests stage

I have a file in some folder on my computer that i want to add to the jenkins pipeline build folder before testing stage, without addind this file to the repository. is there a way to do that? this file is a config.yaml that contains a relevant version.
thanks

Where are Jenkins artifacts located?

I added the Archive Artifacts post-build option to my project. I can see the artifacts from the web browser interface, but I cannot find them in the filesystem.
Where are they located?
It is being archived on the master server (even if the build were on a slave) in the following folder:
$JENKINS_HOME/jobs/<job>/builds/<build>/archive
But you can configure a different location using the 'Advanced' setting of the job (where you can set a different workspace folder) or using plugins that are made for this purpose such as Copy Artifact Plugin
Just another couple of tips...
You can find jenkins home by going to the environment variables page in the job build jenkins page.
In my case JENKINS_HOME turned out to be /var/lib/jenkins
Found artifacts in:
/var/lib/jenkins/jobs/<my-job-name>-build/lastStable/archive/target
/var/lib/jenkins/jobs/<my-job-name>-build/lastSsuccessful/archive/target
as well as
/var/lib/jenkins/jobs/<my-job-name>-build/builds/8/archive/target
Path is : $JENKINS_HOME/jobs//jobs//branches//builds/$BUILD_NUMBER/archive/
You have to extract branch name, job name and repository name from JOB_NAME environment variable.

Jenkins: How to copy files from a Matrix build back to the master and actually use them

I have a multi-configuration Jenkins job which runs my tests in parallel on multiple slave nodes. I want to collect some artifacts from those slave builds back on the master, and then run a post build step to build a custom HTML page from them.
I have everything set up so those files appear to be copied back onto the master, but then I can't seem to access them. Does anybody have a working example of this configuration that they can share?
Here's the job configuration of the matrix axes:
and the build, which just creates a tmp.txt file:
and fingerprint, archiving artifacts and then post build step to copy that file back to the master:
The slave Console Output says the copy succeeded (and we can see from the plugin source code that any error would be reported - and I've definitely seen these errors getting logged when things go wrong):
17:39:23 [copy-to-slave] Copying '**/tmp.txt', excluding nothing, from 'file:/scratch/jenkins/workspace/Test%20Matrix%20Build%202/label/android/node_index/1/' on 'com.cloudbees.jenkins.plugins.mtslavescloud.MansionSlave#c9964fd8' to 'file:/home/<myaccount>/hudson_home/workspace/Test%20Matrix%20Build%202/label/android/node_index/1/' on the master.
However, I can't seem to access those files from a Post Build script running on the master:
17:39:24 + cat label/android/node_index/1/tmp.txt
17:39:24 cat: label/android/node_index/1/tmp.txt: No such file or directory
The files seem to be listed in the Workspace of the master:
I tried versions of the same command using the $WORKSPACE environment variable and they didn't work either, e.g.
20:40:13 + cat '/scratch/jenkins/workspace/Test Matrix Build 2/label/android/node_index/1/tmp.txt'
20:40:13 cat: /scratch/jenkins/workspace/Test Matrix Build 2/label/android/node_index/1/tmp.txt: No such file or directory
...and since "ws" was in the URL I tried adding that in as well (also didn't work):
20:42:51 + cat '/scratch/jenkins/workspace/Test Matrix Build 2/ws/label/android/node_index/1/tmp.txt'
20:42:51 cat: /scratch/jenkins/workspace/Test Matrix Build 2/ws/label/android/node_index/1/tmp.txt: No such file or directory

Publishing to Artifactory using Jenkins

I am trying to use the Generic Jenkins-Artifactory plugin to deploy the contents of the Jenkins build workspace into Artifactory. This seems to be somewhat fine using the following wildcards
Web\*.msi=>Testing\Web
Web\DeploymentSettings\*.xml=>Testing\Web\DeploymentSettings
Database\Scripts\**=>Testing\Database
However, when it comes to moving the contents of 'Database\Scripts' from the Jenkins workspace, empty folders under 'Database\Scripts' do not get copied into Artifactory. Non-empty folders however are copied successfully. It is important that I maintain the directory integrity/structure so it's a must that I copy these across.
I have considered placing empty text files in the empty directories to have them copy over successfully but I don't want to "pollute" the package.
Please help :-)
Thanks!
Looks like there is no workaround -other than dummy files in the directories.
I see some bugs in Jenkins releated to handling empty directories.
JENKINS-7260 Clone workspace doesn't copy empty directories when cloning entire workspace
JENKINS-20654Empty folders are not copied to the slave
Could you check if answer posted in Hudson: Copy artifact from master to slave fails helps?

Rename job in Folder 2 changes job name in Copy Artifact plugin in a job in Folder 1

I think I may have found a bug in either the Copy Artifacts plug-in or the Folders plug-in...
If I change a job name in one folder it causes a configuration change to a job in a different folder.
I am using the Folders plug-in and the Copy Artifact plugin.
I recreated this issue in a clean Jenkins server with the Folders and Copy Artifacts plug-ins installed as follows:
1. Create a folder: Folder 1
2. Create a job: Job 1. This job creates and archives a text file: job1.txt (Windows batch step: echo %JOB_NAME% > job1.txt)
3. Create a second job: Job 2. Configure Job 2 to use the Copy Artifact plug-in to get the job1.txt artifact from Job 1.
4. Run Job 1. The job1.txt file is created and archived
5. Run Job 2. The job1.txt file is successfully retrieved from Job 1.
Copy Folder 1 to Folder 1. (Create a new job Folder 2 and copy existing job Folder 1).
Folder 2 is created containing Job 1 and Job 2.
Rename Folder 2; Job 1 (to Job 1 Renamed)
The Copy Artifact reference in Folder 2; Job 2 is changed as expected.
Inspect Folder 1; Job 2. The Copy Artifact reference has also changed. This is not as expected.
Glenn
Sounds like a bug in Copy Artifact; did you confirm against trunk (since there have been a bunch of unreleased changes) and file it?

Resources