title: Access variable in email ext template using Jenkins pipeline
body: <p>I am trying to attach the template file using Jenkins pipeline, <strong>emailext</strong>. 
  Variable (PROJNAME) is not accessible in the template file and I am receiving exceptions as an email:</p>
  
  <blockquote>
    <p>Exception raised during template rendering: No such property: env for class: SimpleTemplateScript21 groovy.lang.MissingPropertyException: No such property: env for class: SimpleTemplateScript21 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) at SimpleTemplateScript21.run(SimpleTemplateScript21.groovy:1) at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:168) at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:180) at hudson.plugins.emailext.plugins.content.ScriptContent.renderTemplate(ScriptContent.java:151) at hudson.plugins.emailext.plugins.content.ScriptContent.evaluate(ScriptContent.java:82) at org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:208) at org.jenkinsci.plugins.tokenmacro.Parser.processToken(Parser.java:308) at org.jenkinsci.plugins.tokenmacro.Action$KiHW1UeqOdqAwZul.run(Unknown Source) at org.parboiled.matchers.ActionMatcher.match(ActionMatcher.java:96) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351)</p>
  </blockquote>
  
  <p>Pipeline Script:</p>
  
  <pre><code>stage('Email') {
      def mailRecipients = "myemail@abc.com"
      def jobStatus = currentBuild.currentResult
      env.PROJNAME = 'project_name'
      echo "projname is ${PROJNAME}"
  emailext body: '''${SCRIPT, template="test.template"}''',
      mimeType: 'text/html',
      subject: "[Jenkins] ${jobStatus}",
      to: "${mailRecipients}"
  }
  </code></pre>
  
  <p>Template (filename - test.template):</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Page Title&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;This is a Heading&lt;/h1&gt;
  &lt;p&gt;Job is '${env.PROJNAME}'&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Also tried replacing the variable syntax in template file as "<strong>${PROJNAME}</strong>" and "<strong>${ENV, var="PROJNAME"}</strong>" but no luck. Any suggestions?</p>
  
  <p>Didn't help when I replaced with <strong>ENV(var="PROJNAME")</strong> in template file. I received the email as:</p>
  
  <h1>This is a Heading</h1>
  
  <p>Job is ENV(var="PROJNAME")</p>