-
-
Save ictus4u/d5b00d89da1c1c5d914c01d622e747be to your computer and use it in GitHub Desktop.
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
pipeline { | |
agent any | |
parameters { | |
string(defaultValue: '', description: 'The name of the organization working on this repository.', name: 'orgName') | |
} | |
stages{ | |
stage("Create Repo Piplines") { | |
steps { | |
jobDsl scriptText: """ | |
folder (orgName) | |
def orgApi = new URL("https://api.github.com/users/${orgName}/repos") | |
def repos = new groovy.json.JsonSlurper().parse(orgApi.newReader()) | |
repos.each { | |
def repo = it.name | |
def project = "$orgName/\${repo}" | |
folder("\${project}") | |
multibranchPipelineJob("\${project}/Branches") { | |
branchSources { | |
github { | |
scanCredentialsId("$orgName") | |
repoOwner(orgName) | |
repository(repo) | |
} | |
} | |
} | |
pipelineJob("\${project}/Deploy") { | |
parameters { | |
stringParam("DEPLOY_BRANCH") | |
} | |
definition { | |
cpsScm { | |
scm { | |
git { | |
branch('\${DEPLOY_BRANCH}') | |
remote { | |
github("\${project}") | |
credentials("$orgName") | |
} | |
} | |
} | |
scriptPath('Jenkinsfile.deploy') | |
} | |
} | |
} | |
} | |
""" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment