Skip to content

Instantly share code, notes, and snippets.

@ekowcharles
Created May 7, 2020 05:23
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 ekowcharles/633f0d1f3023244efff74c6142814224 to your computer and use it in GitHub Desktop.
Save ekowcharles/633f0d1f3023244efff74c6142814224 to your computer and use it in GitHub Desktop.
def project = 'ekowcharles/jenkins-jobs-repo'
def branchApi = new URL("https://api.github.com/repos/${project}/branches")
def branches = new groovy.json.JsonSlurper().parse(branchApi.newReader())
branches.each {
def branchName = it.name
def jobName = "${project}-${branchName}".replaceAll('/','-')
pipelineJob(jobName) {
triggers {
scm('* * * * *')
}
definition {
cpsScm {
scm {
git("git://github.com/${project}.git", branchName)
}
scriptPath("Jenkinsfile")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment