Jenkins Multibranch Pipeline 失败,因为它在 Groovy Sandbox 中运行 [英] Jenkins Multibranch Pipeline fails because it runs in Groovy Sandbox

查看:44
本文介绍了Jenkins Multibranch Pipeline 失败,因为它在 Groovy Sandbox 中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Jenkins CI/CD 构建配置正在运行,直到我最后一次拉取请求之前没有任何变化,我需要让它再次运行.

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

多分支管道 配置为从 BitBucket SCM 运行 jenkinsfile 但现在失败并出现以下错误;

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 已安装且进程内脚本批准没有列出要批准的内容.

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

Permissive Script Security Plugin 已安装并 jenkins.xml 被修改为包含用于运行 .war-Dpermissive-script-security.enabled=true 标志.

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

这些是基于如何禁用 Jenkins 管道构建的安全检查

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

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

如果我启用 Use Groovy Sandbox 并运行作业,我会得到同样的错误;

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)

如果我禁用 Use Groovy Sandbox,管道脚本将成功完成;

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-WorkspacePipeline-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

  • 如何确保我拥有干净的 Jenkins 配置?
  • 我应该尝试将 Jenkins 从 v2.121.3 降级吗?
  • 推荐答案

    尝试将 Script Security 插件从 v1.45 降级到 v1.44 并重新启动 Jenkins.

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

    我自己在更新插件后遇到了这个问题,虽然我没有使用 Permissive Script Security 插件.

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

    这篇关于Jenkins Multibranch Pipeline 失败,因为它在 Groovy Sandbox 中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆