title: Jenkins Job DSL Dynamic Parallel Steps
body: <p><strong>Current Situation</strong>: Currently in Jenkins 1, I have JobA and JobB running tests using a certain file JobAFile and JobBFile, respectively. The names of the jobs are stored in an array and passed as in a downstreamParameterized trigger. </p>
  
  <p>I am now creating dynamically created files JobAFilePt1, JobBFilePt1, JobBFilePt2, etc. for JobA and JobB, respectively. This requires me to use forMatchingFiles  in parameterFactories. However, JobA has different jobs inside such as JobASubJob1, JobASubJob2, which messes up the forMathcingFiles pattern matching.</p>
  
  <p>To remedy this, I tried to put something like: </p>
  
  <pre><code>JobAJobs.each { String subJob-&gt;
      steps {
          downstreamParameterized {
              trigger('subJob') {
                  paramterFactories {
                      forMatchingFiles("somePattern${subJob}")
                  }
              }
          }
      }
  </code></pre>
  
  <p><strong>Problem</strong>: But this simply makes it run in series. How do I get the steps to run in parallel? Or at least have it not block until the build is done for the trigger? I've looked online and only found solutions for declarative pipelines and scripted pipelines rather than Job DSL. </p>
  
  <p><strong>As another alternate possible solution:</strong> I'm looking at just making this a Phase now, and each phaseJob is created dynamically. However, because I need to pass "n" number of files as parameters to the certain file (which can be found with a pattern), I'm not sure how to approach that end. How do I dynamically give it parameters?</p>
  
  <pre><code>phase("Run jobs") {
      JobAJobs.each { String subJob -&gt; {
          phaseJob("subJob") {
              parameters { 
                  &lt;someParameterType&gt; 
              }
          }
      }
  }
  </code></pre>
  
  <p>In place of someParameterType, I would like to try and pass in File Parameters, but not sure how to approach that. Any suggestions?</p>