title: Jenkins Multibranch Pipeline fails because it runs in Groovy Sandbox
body: <p>My Jenkins CI/CD build configuration was working and nothing changed until my last pull request and I need to get this working again.</p>
  
  <p>The <a href="https://jenkins.io/blog/2015/12/03/pipeline-as-code-with-multibranch-workflows-in-jenkins/" rel="noreferrer">Multibranch Pipeline</a> is configured to run a <code>jenkinsfile</code> from BitBucket SCM but this is now failing with the following error;</p>
  
  <pre><code>groovy.lang.MissingPropertyException: No such property: pipeline for class: groovy.lang.Binding
      at groovy.lang.Binding.getVariable(Binding.java:63)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:130)
  </code></pre>
  
  <p><a href="https://wiki.jenkins.io/display/JENKINS/Script+Security+Plugin" rel="noreferrer">Script Security Plugin</a> is installed and the In-process Script Approval has nothing listed to approve.</p>
  
  <p><a href="https://plugins.jenkins.io/permissive-script-security" rel="noreferrer">Permissive Script Security Plugin</a> is installed and <code>jenkins.xml</code> is modified to include the <code>-Dpermissive-script-security.enabled=true</code> flag for running the <code>.war</code>.</p>
  
  <p>These were implemented and working previously based on <a href="https://stackoverflow.com/questions/37933105">How can I disable security checks for Jenkins pipeline builds</a></p>
  
  <p>As a test I created a Pipeline job which allows the Groovy Sandbox to be enabled and disabled. This was configured with the following cut down version of my pipeline script;</p>
  
  <pre><code>#!groovy
  
  pipeline {
  
      agent any
  
      environment {
          VERSION = "${env.MAJOR_VERSION}.${env.MINOR_VERSION}"
          BUILD_LABEL = "MyProject ${env.VERSION} Build #${env.BUILD_NUMBER}"
          BUILD_SOURCESDIRECTORY = "${WORKSPACE}\\src"
      }
  
      options {
          copyArtifactPermission('MyProject-Deploy')
          buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '5'))
      }
  
      parameters {
          string (
              defaultValue: '3',
              description: 'MyProject Major Version',
              name : 'MAJOR_VERSION')
          string (
              defaultValue: '7',
              description: 'MyProject Minor Version',
              name : 'MINOR_VERSION')
      }
  
      stages {
  
          stage('Checkout Source') {
              steps {             
                  echo('checkout scm')                
              }
          }
      }
  }
  </code></pre>
  
  <p>If I enabled <code>Use Groovy Sandbox</code> and run the job I get the same error;</p>
  
  <pre><code>Running in Durability level: MAX_SURVIVABILITY
  [Pipeline] End of Pipeline
  groovy.lang.MissingPropertyException: No such property: pipeline for class: groovy.lang.Binding
      at groovy.lang.Binding.getVariable(Binding.java:63)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:130)
  </code></pre>
  
  <p>If I disable <code>Use Groovy Sandbox</code> the pipeline script completes successfully;</p>
  
  <pre><code>Running in Durability level: MAX_SURVIVABILITY
  [Pipeline] node
  Running on Jenkins in C:\Jenkins-Workspace\Pipeline-Test
  [Pipeline] {
  [Pipeline] withEnv
  [Pipeline] {
  [Pipeline] stage
  [Pipeline] { (Checkout Source)
  [Pipeline] echo
  checkout scm
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  Finished: SUCCESS
  </code></pre>
  
  <ul>
  <li>How do I ensure I have a clean Jenkins configuration?</li>
  <li>Should I attempt to downgrade Jenkins from v2.121.3?</li>
  </ul>