Here is the content of my Jenkinsfile
:
node {
// prints only the first element \'a\'
[ \'a\', \'b\', \'c\' ].each {
echo it
}
}
A workaround for this issue is to expand all the commands to a flat text file as a groovy script. Then use load step to load the file and execute.
For example:
@NonCPS
def createScript(){
def cmd=""
for (i in [ 'a', 'b', 'c' ]) {
cmd = cmd+ "echo $i"
}
writeFile file: 'steps.groovy', text: cmd
}
Then call the function like
createScript()
load 'steps.groovy'