title: Jenkins DSL - Parse Yaml for complex processing
body: <p>I'm using Jenkins Job DSL to construct pipelines for multiple SOA style services. All these service pipelines are identical.</p>
  
  <pre><code>job('wibble') {
    publishers {
      downstreamParameterized {
        trigger("SOA_Pipeline_Builder") {
          condition('SUCCESS')
          parameters {
            predefinedProp('PROJECT_NAME', "myproject-2"             )
            predefinedProp('PROJECT_REPO', "myprojecttwo@gitrepo.com" )
          }
        }
        trigger("SOA_Pipeline_Builder") {
          condition('SUCCESS')
          parameters {
            predefinedProp('PROJECT_NAME', "myproject-1"             )
            predefinedProp('PROJECT_REPO', "myprojectone@gitrepo.com" )
          }
        }
      }
    }
  }
  </code></pre>
  
  <hr>
  
  <p>Given I'm adding in new projects everyday, I have to keep manipulating the DSL. I've decided that i'd rather have all the config in a yaml file outside of the DSL. I know I can use groovy to create arrays, do loops etc, but I'm not having much luck.
  I'm trying to do something like this...</p>
  
  <pre><code>@Grab('org.yaml:snakeyaml:1.17')
  import org.yaml.snakeyaml.Yaml
  List projects = new Yaml().load(("conf/projects.yml" as File).text)
  
  job('wibble') {
    publishers {
      downstreamParameterized {
        projects.each {
          trigger("SOA_Pipeline_Builder") {
            condition('SUCCESS')
            parameters {
              predefinedProp('PROJECT_NAME', it.name )
              predefinedProp('PROJECT_REPO', it.repo )
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>conf/projects.yml</p>
  
  <pre><code>---
  - name: myproject-1
    repo: myprojectone@gitrepo.com
  - name: myproject-2
    repo: myprojecttwo@gitrepo.com
  </code></pre>
  
  <hr>
  
  <p>Does anyone have any experience with this sort of thing?</p>