Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Update a Scan Repository Trigger in a Jenkins GitHub Cloudbees folder
// Update the PeriodicFolderTrigger of each job inside of a Cloudbees folder.
// Useful for updating individual repos as you cannot do this through the UI.
import com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger
import jenkins.model.Jenkins
import jenkins.branch.OrganizationFolder
println "Multibranch Items\n-------"
Jenkins.instance.getAllItems(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject.class).each { it.triggers
.findAll { k,v -> v instanceof com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger }
.each { k,v -> setInterval(it) }
def setInterval(folder) {
println "[INFO] : Updating ${}... "
folder.getTriggers().find {triggerEntry ->
def key = triggerEntry.key
if (key instanceof PeriodicFolderTrigger.DescriptorImpl){
println "[INFO] : Current interval : " + triggerEntry.value.getInterval()
// Valid intervals are here:
def newInterval = new PeriodicFolderTrigger("28d")
println "[INFO] : New interval : " + newInterval.getInterval()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.