Groovy .each only iterates one time

前端 未结 3 1375
攒了一身酷
攒了一身酷 2020-12-09 18:08

The script is not iterating through all the values of the \'modules\' array.

class Module {
    public String name =         


        
3条回答
  •  一个人的身影
    2020-12-09 18:50

    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 entry : currentBuild.build().environment) {
        str += "    ${entry.key} = ${entry.value}\n"
      }
      echo str
    }
    
    return this;
    

提交回复
热议问题