title: How to create an extendable base job in Jenkins Job DSL?
body: <p>I'm trying to create a base job, to reduce the duplication between our jobs. I did the following, but it's not working:</p>
  
  <pre><code>def baseJob(Map m, Closure c = {}) {
      type = m.type ?: 'dev'
      pipelineJob("prefix-${m.name}") {
          parameters {
              stringParam('ONE', 'one', 'Description one')
          }
          c()
      }
  }
  
  baseJob(type: 'release', name: 'test') {
      parameters { // &lt;-- Fails here
          stringParam('TWO', 'two', 'Description two')
      }
  }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>ERROR: (script, line 12) No signature of method: script.parameters() is applicable for argument types: (script$_run_closure1$_closure4) values: [script$_run_closure1$_closure4@18b249b3]</p>
  </blockquote>
  
  <p>The following works as expected:</p>
  
  <pre><code>def baseJob(Map m, Closure c = {}) {
      type = m.type ?: 'dev'
      pipelineJob("prefix-${m.name}") {
          parameters {
              stringParam('ONE', 'one', 'Description one')
          }
          parameters { // &lt;-- This is fine
              stringParam('TWO', 'two', 'Description two')
          }
          c()
      }
  }
  
  baseJob(type: 'release', name: 'test')
  </code></pre>
  
  <p>So the problem isn't that I call <code>parameters</code> multiple times. The problem seems to be that I call <code>parameters</code> from inside a closure.</p>
  
  <p>I'd like to believe that there is a way to execute the closure, so that <code>parameters</code> is called correctly. However, I suspect that I will have to learn a lot more about Groovy and Jenkins Job DSL, before I am able to figure it out. So I'm hoping that there is someone that knows how to do it.</p>
  
  <p>If you have an alternative solution to accomplishing an extendable base job, that's a valid answer as well.</p>