Skip to content

Instantly share code, notes, and snippets.

@stephenmenton
Last active May 22, 2019 20:29
Show Gist options
  • Save stephenmenton/2d52c9477cea62b4d0336a5bbff93bdc to your computer and use it in GitHub Desktop.
Save stephenmenton/2d52c9477cea62b4d0336a5bbff93bdc to your computer and use it in GitHub Desktop.
need to remove triggers from multibranch pipeline jobs
def job = Jenkins.instance.getItemByFullName('/path/to/multibranchPipeline')
job.triggers.forEach { k, v ->
println "k: ${k}"
println "v: ${v}"
if (k instanceof com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger$DescriptorImpl) {
println "match, removing"
job.triggers.remove(k)
}
}
job.save()
println "and then..."
job.triggers.forEach { k, v ->
println "k: ${k}"
println "v: ${v}"
}
// "But... the job refused to change."
// triggers is a readonly field in org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment