Jenkins Multibranch Pipeline fails because it runs

2020-04-07 04:05发布

My Jenkins CI/CD build configuration was working and nothing changed until my last pull request and I need to get this working again.

The Multibranch Pipeline is configured to run a jenkinsfile from BitBucket SCM but this is now failing with the following error;

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)

Script Security Plugin is installed and the In-process Script Approval has nothing listed to approve.

Permissive Script Security Plugin is installed and jenkins.xml is modified to include the -Dpermissive-script-security.enabled=true flag for running the .war.

These were implemented and working previously based on How can I disable security checks for Jenkins pipeline builds

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;

#!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')                
            }
        }
    }
}

If I enabled Use Groovy Sandbox and run the job I get the same error;

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)

If I disable Use Groovy Sandbox the pipeline script completes successfully;

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
  • How do I ensure I have a clean Jenkins configuration?
  • Should I attempt to downgrade Jenkins from v2.121.3?

2条回答
Summer. ? 凉城
2楼-- · 2020-04-07 04:41

Try downgrading the Script Security plugin from v1.45 to v1.44 and restarting Jenkins.

Just ran into this myself after updating plugins, although I'm not using the Permissive Script Security plugin.

查看更多
祖国的老花朵
3楼-- · 2020-04-07 04:48

It's fixed in version 1.46 of the script-security plugin.

查看更多
登录 后发表回答