I have the following setup:
A Jenkins multi-branch pipeline job configured through Jenkinsfile
. After successful checkout and build, the artifact is archived and a downstream job is triggered to deploy the generated artifact.
For the second job to be able to copy the artefact through the [$class: 'CopyArtifact'...
step, it needs copy permissions.
So the question is, how do I grant those permissions through the Jenkinsfile
of the upstream job?
Next you need to install the Copy Artifact plugin in the Manage Plugins section of Jenkins. Go to "[PROJECT-NAME]-Output" > configure and add a new build step. Because you have installed the Copy Artifact plugin you should see an option called 'copy artifacts from another project' in the drop down menu.
How to Create an Artifact. In Jenkins, an artifact is created in either Freestyle projects or Pipeline projects. In Freestyle, add the “Archive the artifacts” post-build step. In Pipeline, use the archiveArtifacts step.
In declarative pipelines, this is the preferred syntax:
options {
copyArtifactPermission('my-downstream-project');
}
Available from version 1.41 of Copy Artifact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With