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

查看:1008
本文介绍了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 is installed and the In-process Script Approval has nothing listed to approve.

已安装许可脚本安全插件,并对jenkins.xml进行了修改,以包括-Dpermissive-script-security.enabled=true标志,用于运行.war.

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管道构建禁用安全检查

作为测试,我创建了一个Pipeline作业,该作业允许启用和禁用Groovy Sandbox.这是使用以下简化版本的管道脚本配置的;

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

  • 如何确保我拥有干净的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天全站免登陆