Skip to content

Instantly share code, notes, and snippets.

@matthiasbaldi
Created August 20, 2018 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthiasbaldi/a19d1d79a905184f285ebe235c0f053a to your computer and use it in GitHub Desktop.
Save matthiasbaldi/a19d1d79a905184f285ebe235c0f053a to your computer and use it in GitHub Desktop.
Jenkins set PeriodicFolderTrigger for multiple Items
def counter = 0
for (f in Jenkins.instance.getAllItems(jenkins.branch.MultiBranchProject.class)) {
if (f.parent instanceof jenkins.branch.OrganizationFolder) {
// managed by org folder, leave alone
continue;
}
if (f.name.matches(/.*api.*/)) {
println "set config for: ${f.name}"
// addTrigger will replace an existing one
f.addTrigger(new com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger("30m"));
counter++
}
}
println "---------------------------------------------"
println "updated elements: ${counter}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment