Last active
October 2, 2020 21:09
-
-
Save phnahes/901b92ec00fb4837be28b8088ef03bd5 to your computer and use it in GitHub Desktop.
Jenkinsfile - Dinamic stages
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
#!/usr/bin/env groovy | |
def list | |
pipeline { | |
agent none | |
stages { | |
stage('Create List') { | |
agent any | |
steps { | |
script { | |
//list = ["Test-1", "Test-2", "Test-3", "Test-4", "Test-5"] | |
/* Services comming from parameterized build vars */ | |
list = "${SERVICE}".split(","); | |
} | |
} | |
post { | |
cleanup { | |
cleanWs() | |
} | |
} | |
} | |
stage('Dynamic Stages') { | |
agent any | |
steps { | |
script { | |
for(int i=0; i < list.size(); i++) { | |
stage(list[i]){ | |
echo "Element: $i" | |
} | |
} | |
} | |
} | |
post { | |
cleanup { | |
cleanWs() | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment