title: Access to build environment variables from a groovy script in a Jenkins build step (Windows)
body: <p>I'm using Scriptler plugin, so I can run a groovy script as a build step. My Jenkins slaves are running on windows in service mode. With scriptler, I don't need to use windows batch scripts.</p>
  
  <p>But I have trouble to get the environment variables in a build step... This is working:</p>
  
  <pre><code>System.getenv("BASE")
  </code></pre>
  
  <p>Where <code>BASE</code> is part of the env-vars on jenkins startup. However, I would like to get </p>
  
  <pre><code>%JOB_NAME%
  </code></pre>
  
  <p>If I'm adding an "Execute Windows batch command" build step:</p>
  
  <pre><code>echo %JOB_NAME%
  </code></pre>
  
  <p>It works.
  If I'm adding a scriptler script as a build step with the same settings:</p>
  
  <pre><code>println "JOB_NAME: " + System.getenv("JOB_NAME")
  </code></pre>
  
  <p>I'm getting: </p>
  
  <pre><code>JOB_NAME: null
  </code></pre>
  
  <p>So how can I reach the injected environment variables from a groovy script as a build step?</p>