Jenkins - access archived artifacts from downstream job - jenkins

I'm a little confused on what exactly jenkins (2.74) is doing when archiving artifacts from a maven project. It appears from the logs that jenkins is automatically archiving artifacts in the project without having to specify a post-build action. The artifact files are indeed in the jobs/<project>/modules subdirectory and are available for download from the jenkins webui.
When triggering a follow-on job, I've added a build step to copy artifacts from the upstream (which build: upstream build that triggered this job) without specifying artifacts. The log files for the downstream state that is has copied artifacts from the upstream job. But I'm unable to see them in the workspace.
Are the artifacts available to the downstream job? If so, where are they?
Or do I need to explicitly archive the artifacts (with filenames) in the upstream job and explicitly copy the artifacts by filename in the downstream job?

In your downstream job, you should set this kind of configuration:
To specify the artifacts you want to retrieve from your upstream job and where you can to copy them.
In your case, we copy the openidm-zip file into a local "archives" folder.

Related

Archieve artificate is copies wrong artifacts

I have jenkins job which copies artifacts from another job using Copy Artifacts from another job configuration, when we run the job alone it copies latest successful build artifacts, however when we try to run it from up stream job it is wrongly copying artifacts
In both scenarios it should copy latest artifacts

Does 'Archive artifacts only if build is successful' set as true means, any artifacts won't be created in Jenkins if build fails?

I am running a an automation script in Jenkins . Does 'Archive artifacts only if build is successful' set as true means, any artifacts won't be created in Jenkins if build fails ? OR does this means the artifacts are created in the specified folder,but they are not saved for later and once delete workspace is run,the artifacts created will be gone forever.
Archiving artifacts in jenkins means that the artifacts will be saved on the Jenkins master (for later usage). Even if the job is finished and the workspace is cleaned.
For example for maven this setting means: if your maven build is successful (no failures) then the created artifacts (jars, wars or an ear) will be archived/stored on the Jenkins master and you can safely clean the workspace.
I don't know mortar but in your case this will probably also mean: if the build is successful on your Jenkins slave, then your Artifacts will be copied to the jenkins master and stored there. If you clean your workspace after the build or just not isn't related.

Jenkins Permission to Copy Artifact is always granted

I am trying to make our Jenkins setup more secure, but I am unable to protect artifacts with the Permission to Copy Artifact option.
I have two jobs, where the downstream job copies artifacts from the upstream job by using the Copy Artifact Plugin. This works as expected. Now I want to ensure that only this specific downstream job can copy the artifacts of the upstream job, but that doesn't seem to work.
As far as I understand, you should specify the name of the downstream job in the Permission to Copy Artifact option of the upstream job. I tried this, but no matter what I configure in the Permission to Copy Artifact option of the upstream job, the downstream job is always allowed to copy the artifacts.
So I would like to know: are there any global options that must be enabled or disabled for this to work? Is there something else that I must configure before the permission to Copy Artifact option actually limits permissions?
Edit: I'm using version Copy Artifact Plugin 1.38.1.
Since Copyartifact 1.30, there is a limitation "Permission to Copy Artifacts" accepts only relative project names.
If you use CloudBees Folders Plugin and the projects are located in different folders, you need to specify project names like "../folder/project".
This is fixed in Copyartifact 1.31.
detail link : https://wiki.jenkins.io/display/JENKINS/Copy+Artifact+Plugin

copy file from workspace of the upstream running build

I'm using a Jenkins job to trigger a few downstream jobs. I pass parameters through properties file. But there's a file that was uploaded when the upstream job was submitted that I want to pass to the downstream jobs. There is an option under Copy Artifact Plugin that allows copying from the workspace of the latest completed upstream job.
The problem is that my upstream job is blocked on the downstream jobs and cannot complete before them. This is the same reason that I cannot copy the file as an artifact, as archiving artifacts is only possible as a post-build action (AFAIK).
Is there any way around this problem?
You could you stick the uploaded artifact in the upstream job into an online file repository like Artifactory or an external network/file share and access it in the downstream job?
That way, you just need to pass in the path of the file rather than the entire file and can download it in the child.
You could even use the build number of the upstream job as the unique identifier of the artifact, so you just need to pass the build number down to download it.
http://myonlinerepository/{build number}/upload.zip

How to copy the artifacts from slave to Jenkins workspace?

I'm running a jenkins job on a slave and i want to store the generated artifacts in the server.Since the job is currently running on the slave the artifacts are also created there.
I tried using post build actions --->archive the artifacts.But it throws the following build error
ERROR: No artifacts found that match the file pattern "**/*.gz". Configuration error?
ERROR: '**/*.gz' doesn't match anything: '**' exists but not '**/*.gz'
Any help in this regards is highly appreciated.
Sounds like Copy To Slave Plugin is what you need
It can copy to slave (before build) and from slave (after build)
Copy files back to master node:
To activate this plugin for a given job, simply check the Copy files back to the job's workspace on the master node checkbox in the Post-build Actions section of the job. You then get the same two fields as for the Copy files to slave node before building section (note that label in the screenshot is old):
if you want to copy artifacts from JobA to the workspace of some other Job, you can do it using the Copy Artifact Plugin which is very simple to understand.
In case you just want to archive the artifacts already in JobA, then you are already in this direction and need to check what you are missing... are you sure that the artifacts are in the current workspace?
Doron

Resources