Created
March 3, 2021 17:19
-
-
Save afischer211/de11238440dab2cf78cde1cb2c7a8f28 to your computer and use it in GitHub Desktop.
Dynamic stages based on yaml-file #Jenkins #Pipeline
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
| 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