3
votes

I am trying to add a call to my jenkins job dsl that will configure the job to give permission to another build to copy artifacts. However, I am unable to find a command for it in the Jenkins Job DSL API: https://jenkinsci.github.io/job-dsl-plugin/

Here is the option I am trying to set using the DSL:enter image description here

Does this command exist? Is there anyways to setup my groovy to do this if it doesnt?

3

3 Answers

6
votes

There is no built-in DSL to set that permission, but you can use the Automatically Generated DSL:

job('example') {
  properties {
    copyArtifactPermissionProperty {
      projectNames('one, two')
    }
  }
} 
2
votes

is it this one?

job('example') {
    steps {
        copyArtifacts('upstream') {
            includePatterns('*.xml', '*.properties')
            excludePatterns('test.xml', 'test.properties')
            targetDirectory('files')
            flatten()
            optional()
            buildSelector {
                latestSuccessful(true)
            }
        }
    }
}

EDIT It seems this may have been fixed in the google group for job-dsl

configure { project ->
  project / 'properties' / 'hudson.plugins.copyartifact.CopyArtifactPermissionProperty' / 'projectNameList' {
    'string' "*-foo"
  }
}

I think they may have changed the interface though and you need to provide explicit job names now, but I haven't got the plugin so I can't check

1
votes

I have just had this problem, and this what worked for me:

properties([
   copyArtifactPermission('*')
])

The wild star should be replaced with a coma separated list of projects that need to copy artefacts from this project.