我的Jenkins CI / CD构建配置正常工作,直到我上一次拉取请求才发生变化,我需要重新开始工作。
Multibranch Pipeline配置为从BitBucket SCM运行jenkinsfile
,但现在失败,出现以下错误;
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,并且进程内脚本批准没有列出任何要批准的内容。
安装Permissive Script Security Plugin并修改jenkins.xml
以包括用于运行-Dpermissive-script-security.enabled=true
的.war
标志。
这些是先前基于How can I disable security checks for Jenkins pipeline builds实施和工作的
作为测试,我创建了一个Pipeline作业,允许启用和禁用Groovy Sandbox。这是使用我的管道脚本的以下减少版本配置的;
#!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')
}
}
}
}
如果我启用Use Groovy Sandbox
并运行该作业,我会得到相同的错误;
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)
如果禁用Use Groovy Sandbox
,管道脚本将成功完成;
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
尝试将Script Security插件从v1.45降级到v1.44并重新启动Jenkins。
虽然我没有使用Permissive Script Security插件,但在更新插件后我自己也遇到了这个问题。
它已在script-security插件的1.46版本中修复。