Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins DSL API for copyartifact permissions

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?

like image 765
Josh Starrett Avatar asked Oct 15 '25 07:10

Josh Starrett


2 Answers

There is no built-in DSL to set that permission, but you can use the Dynamic DSL.
The Job DSL API viewer can be opened at http://localhost:8080/plugin/job-dsl/api-viewer/index.html where localhost is your Jenkins host. Search for copyArtifactPermission as an example:

job('example') {
  properties {
    copyArtifactPermissionProperty {
      projectNames('one, two')
    }
  }
} 
like image 79
daspilker Avatar answered Oct 18 '25 10:10

daspilker


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

like image 39
KeepCalmAndCarryOn Avatar answered Oct 18 '25 09:10

KeepCalmAndCarryOn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!