8

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?

TheRock3t
  • 628
  • 9
  • 22

2 Answers2

9

In declarative pipelines, this is the preferred syntax:

options {
    copyArtifactPermission('my-downstream-project');
}

Available from version 1.41 of Copy Artifact.

Raphael
  • 9,779
  • 5
  • 63
  • 94
2

For Scripted Pipeline Syntax, this works:

  properties([[$class: 'CopyArtifactPermissionProperty', projectNames: 'Other Project Name'], [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false], pipelineTriggers([])])

Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49