title: Jenkins: join multiple DSL files in one
body: <p>I'd like to unify Jenkins job generation process and want to have one single file that I would pass to <strong>Process Job DSLs</strong> step.</p>
  
  <p>So I could vary files that included in current release of DSL. Say I have these files:</p>
  
  <pre><code>..
  Release.groovy
  FirstPipeline.groovy
  SecondPipeline.groovy
  </code></pre>
  
  <p>And I want Release.groovy to include either both pipelines or maybe just single pipeline.</p>
  
  <p>Inside pipeline files there is no Class structure, so I cannot <strong>import</strong> them as if they were a library. It has just something like this:</p>
  
  <pre><code>import mylibs.jobs.UsefulJob1
  import mylibs.jobs.UsefulJob2 
  import mylibs.jobs.FirstPipeline
  
  def firstPipeline = new FirstPipeline()
  
  multiJob(firstPipeline.name) {
    // multijob steps
  }
  </code></pre>
  
  <p>I tried to use <strong>evaluate</strong>, but it turned out that it works only for simple scripts. And if you use it with more complex hierarchy of imported libraries and meta programming it fails with hardly interpretable errors.</p>