title: Set Jenkins Environment variables via Groovy script
body: <p>I'd like to set Jenkins Global Properties - Environment variables  via Groovy script (YAML file) which is executed in Ansible.<br>
  I've tried following </p>
  
  <pre><code>import jenkins.*
  import jenkins.model.*
  import hudson.*
  import hudson.model.*
  instance = Jenkins.getInstance()
  envVars.put("FOO1", "bar1")
  envVars.put("FOO2", "bar2")
  instance.save()
  </code></pre>
  
  <p>Why is this not working?</p>