title: Groovy: evaluate a property with a variable in it
body: <p>A bit new to groovy, I am trying to match a variable string to a property pulled from a file using ConfigSlurper. I have the slurper part working fine, but can't seem to figure out the right way to evaluate a property with a variable in it. I think I was getting warm when I found <a href="http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/" rel="nofollow">evaluating-code-dynamically-in-groovy</a> but I am not entirely sure. </p>
  
  <pre><code>//properties.groovy
  jobs {
    foo {
      email="foo@email.com"
    }
  }
  
  //myscript.groovy
  def config = new ConfigSlurper().parse(new File('properties.groovy').toURI().toURL())
  
  List jobs = (ArrayList) BazAPI.getArtifacts(bucket) // list of objects, foo is one
  ListIterator jobIterator = jobs.listIterator();
  
  while (jobIterator.hasNext()) {
      Object j = jobIterator.next();
      job_name = "${j.name}" //
      email = config.jobs."${job_name}".email /* NEED TO FIGURE OUT HOW TO EVAL */
      foo_email = config.jobs.foo.email //evaluates to the correct property in properties.groovy
  
      //these values get fed to a DSL but to illustrate
      println "${job_name}"    // prints foo
      println "${email}"       // prints [:]
      println "${foo_email}"   // prints foo@email.com
  } 
  </code></pre>