title: Simple Jenkins pipeline fails when I check an environment variable
body: <p>In my multibranch pipeline job, I can successfully access environment variables like this:</p>
  
  <pre><code>echo "$env.BRANCH_NAME"
  </code></pre>
  
  <p>But it throws and exception if I try to compare against that same environment variable:</p>
  
  <pre><code>if($env.BRANCH_NAME == 'master')
  {
    echo "This is the master branch"
  }
  </code></pre>
  
  <p>Here's the top of the error stack I'm given:</p>
  
  <pre><code>groovy.lang.MissingPropertyException: No such property: $env for class: groovy.lang.Binding
      at groovy.lang.Binding.getVariable(Binding.java:63)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224)
      at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
      at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28)
      at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
      at WorkflowScript.run(WorkflowScript:4)
  </code></pre>
  
  <p>Do I need to do some sort of script approval here?  I checked in Manage Jenkins -> In-Process Script Approval, but nothing is there.  </p>