Created
May 25, 2021 13:58
-
-
Save cvakiitho/4963a9132e66089d4cab4dacad422163 to your computer and use it in GitHub Desktop.
Jenkins trigger all branch jobs in organization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://javadoc.jenkins.io/jenkins/model/Jenkins.html#getItemByFullName-java.lang.String- | |
def organization = Hudson.instance.getItemByFullName('S4-FIORI-CORE-1 GitHub Quality') | |
if (!organization) throw new Exception("No organization by that name") | |
// https://javadoc.jenkins.io/plugin/cloudbees-folder/com/cloudbees/hudson/plugins/folder/AbstractFolder.html#getItems-- | |
def jobs = organization.getItems() | |
jobs.each { | |
// find the sub-job that's named "master" | |
// https://javadoc.jenkins.io/hudson/model/Item.html#getName-- | |
main = it.items.find { it.getName() == "main" } | |
// if found, schedule a build with 0 quiet period | |
if ( main ) { | |
// ttps://javadoc.jenkins.io/plugin/workflow-job/org/jenkinsci/plugins/workflow/job/WorkflowJob.html#scheduleBuild2-int-hudson.model.Action...- | |
main.scheduleBuild2(0) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment