Skip to content

Instantly share code, notes, and snippets.

@afischer211
Created March 3, 2021 17:19
Show Gist options
  • Select an option

  • Save afischer211/de11238440dab2cf78cde1cb2c7a8f28 to your computer and use it in GitHub Desktop.

Select an option

Save afischer211/de11238440dab2cf78cde1cb2c7a8f28 to your computer and use it in GitHub Desktop.
Dynamic stages based on yaml-file #Jenkins #Pipeline
stage('Build Modules') {
agent { any }
steps {
script {
// def modules = readYaml file: "${env.YAML_FILE}"
def modules = readYaml text:"""
build:
path: 'release'
modules:
"mod1":
git:
branch: master
projects:
- '.'
"""
def fsPath="${modules.build.path}"
def stages = modules.modules.collectEntries { label, props ->
[(label): {
stage(label) {
timeout(time: 30, activity: true, unit: 'MINUTES') { // timeout on this stage after 30mins of no activity
buildModule("${props.git.branch}", label, (String[]) props.projects)
}
}
}]
}
parallel stages
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment