代码之家  ›  专栏  ›  技术社区  ›  Dave Anderson

Jenkins Multibranch管道由于在Groovy沙盒中运行而失败

  •  5
  • Dave Anderson  · 技术社区  · 6 年前

    这个 Multibranch Pipeline 配置为运行 jenkinsfile 从BitBucket SCM,但现在失败,错误如下:;

    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

    作为测试,我创建了一个管道作业,允许启用和禁用Groovy沙盒。这是用我的管道脚本的以下精简版本配置的;

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

    使用Groovy沙盒 管道脚本成功完成;

    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
    
    • 我是否应该尝试从v2.121.3降级Jenkins?
    2 回复  |  直到 6 年前
        1
  •  7
  •   David Lord    6 年前

    尝试将脚本安全插件从v1.45降级到v1.44,然后重新启动Jenkins。

        2
  •  3
  •   tarantoga    6 年前

    它在脚本安全插件的1.46版本中被修复。