title: Simple parallel execution in Jenkins for an array
body: <p>I'm having trouble running a <strong>Jenkins</strong> job using Groovy, and it seems super simple but I'm 1) a noob at Java/Groovy and 2) all the examples I can find are not quite what I need to do.</p>
  
  <p>I found the following similar question:
  <a href="https://stackoverflow.com/questions/42039851/jenkins-groovy-parallel-variable-not-working">Jenkins Groovy Parallel Variable not working</a>, but that <strong>exact</strong> code results in an error:</p>
  
  <blockquote>
    <p>java.lang.UnsupportedOperationException: Calling public static
    java.util.List
    org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(java.lang.Object,groovy.lang.Closure)
    on a CPS-transformed closure is not yet supported (JENKINS-26481);
    encapsulate in a @NonCPS method, or use Java-style loops</p>
  </blockquote>
  
  <p>Here's my pseudo-code of what I want to do:</p>
  
  <pre><code>String[] arr = [ "one","two","three",'four','five' ]
  echo "Running commands: ${arr}"
  int top = arr.size()
  echo "top is ${top}"
  parallel arr.each {
      echo "${it}"
  }
  </code></pre>
  
  <p>I've tried closures, but they throw an error and honestly I barely know how to use them.
  The following code </p>
  
  <pre><code>String[] arr = [ "one","two","three",'four','five' ]
  echo "Running commands: ${arr}"
  
  parallel arr.collect { item -&gt;
      { -&gt; 
          echo "${item}"
      }
  }
  </code></pre>
  
  <p>throws the same "java.lang.UnsupportedOperationException" as the related question above.</p>
  
  <p>I'm trying to learn how to properly utilize Groovy with Jenkins, but it's been rough.  Just looking for any help I can get at this point.</p>
  
  <p>Thank you.</p>