title: Jenkins Build Flow Plugin sequentially chain multiple jobs in parallel
body: <p>I'm attempting to replicate this functionality from the Build Flow Plugin: <a href="https://wiki.jenkins-ci.org/display/JENKINS/Build+Flow+Plugin" rel="nofollow noreferrer">https://wiki.jenkins-ci.org/display/JENKINS/Build+Flow+Plugin</a>:</p>
  
  <pre><code>parallel (
      {
          build("job1")
          build("job2")
      },
      {
          build("job5")
          build("job6")
      }
  )
  </code></pre>
  
  <p>I have the following DSL job:</p>
  
  <pre><code>subjob = "test"
  subjob2 = "test2"
  series1 = []
  series2 = []
  subjob = []
  
  ["job1","job2"].each{ parameter -&gt;
    series1.add({build( subjob, param: parameter )})
  }
  
  ["job5","job6"].each{ parameter2 -&gt;
    series2.add({build( subjob2, param: parameter2)})
  }
  
  subjob.add(series1)
  subjob.add(series2)
  
  parallel( subjob )
  </code></pre>
  
  <p>My goal is to run one set of jobs 1&amp;2 in series and another set of jobs 5&amp;6 in series, but to run both sets of jobs in parallel. i.e. Job 1 and 5 kick off at the same time, then when job 1 finishes job 2 start and when job 5 finishes job 6 starts.</p>
  
  <p>However, I've tried a number of variations on the above code, but different errors each time.  The above code gives the following:</p>
  
  <pre><code>ERROR: Failed to run DSL Script
  org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[Script1$_run_closure1$_closure3@3c52c84, Script1$_run_closure1$_closure3@56789ba0]' with class 'java.util.ArrayList' to class 'groovy.lang.Closure' due to: groovy.lang.GroovyRuntimeException: failed to invoke constructor: public groovy.lang.Closure(java.lang.Object,java.lang.Object) with arguments: [Script1$_run_closure1$_closure3@3c52c84, Script1$_run_closure1$_closure3@56789ba0] reason: java.lang.InstantiationException
  </code></pre>
  
  <p>Is there a better way of doing this?</p>