How to use for loop in Jenkins declarative pipeline
I am having a list of variable like below
allModules = ['module1', 'module2', 'module3', 'module4', 'module11']
I want to use loop then print all the module one by one.
Please let me know the syntax and how to perform this in Jenkins Declarative pipeline
Solution 1:
Pure declarative pipelines don't support loops. Use a script step. There's actually an example on that page that does exactly what you want.
A more readable and concise (IMO) solution would use iterators, like so:
steps {
script {
allModules.each() {
echo it
}
}
}