The script is not iterating through all the values of the \'modules\' array.
class Module {
public String name =
The workaround is to simply use an old school for loop (code below)
.
Also, NonCPS is another workaround.
There is an open issue for this matter. See here: https://issues.jenkins-ci.org/browse/JENKINS-26481
Update, Oct 24th, 2016
/** * Dumps environment varibles to the log, using an old school for loop. */
import com.cloudbees.groovy.cps.NonCPS
def version = '1.0'
@NonCPS
def dumpEnvVars() {
def str = "Dumping build environment variables...\n"
for (Map.Entry<String, String> entry : currentBuild.build().environment) {
str += " ${entry.key} = ${entry.value}\n"
}
echo str
}
return this;
The messages "Running: Print Message" and "Running: End of Workflow" indicate that you are using the new workflow plugin: https://wiki.jenkins-ci.org/display/JENKINS/Workflow+Plugin. This plugin currently has a bug causing at least some Groovy iterations involving a closure to be aborted after one iteration: https://issues.jenkins-ci.org/browse/JENKINS-26481
As of yesterday, the new Pipeline plugin was delivered in version 2.0 and correct this problem.
.each
closures now work, but .collect
still only iterate once.