Jenkins声明性管道抛出org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException:未分类的getAt方法 [英] Jenkins declarative pipeline throws org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified getAt method

查看:262
本文介绍了Jenkins声明性管道抛出org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException:未分类的getAt方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jenkins中定义了一个共享库:

I have defined a shared library in Jenkins:

import com.codependent.jenkins.pipelines.Utils

def call(List<String> mavenGoals){
  def processedMavenGoals = mavenGoals.join ' '
  pipeline {
    agent any
  ...
}

如果我这样从项目的Jenkinsfile调用它,它就可以正常工作:

If i call this from my project's Jenkinsfile like this it works ok:

#!groovy
@Library('jenkins-pipeline-shared-library-example') _
buildPipeline(['clean', 'install'])

但是,如果我在Groovy语法允许的情况下忽略了感觉异常,则:

However if I omit the parethesis as Groovy syntax allows:

#!groovy
@Library('jenkins-pipeline-shared-library-example') _
buildPipeline ['clean', 'install']

执行将显示以下异常.为什么?

The execution shows the folloing exception. Why?

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified getAt method buildPipeline[java.util.ArrayList]
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetArray(SandboxInterceptor.java:451)
    at org.kohsuke.groovy.sandbox.impl.Checker$10.call(Checker.java:413)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetArray(Checker.java:418)
    at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getArray(SandboxInvoker.java:45)
    at com.cloudbees.groovy.cps.impl.ArrayAccessBlock.rawGet(ArrayAccessBlock.java:21)
    at WorkflowScript.run(WorkflowScript:3)
    at ___cps.transform___(Native Method)

推荐答案

在更新詹金斯之后,我遇到了类似的问题.

I have had a similar issue after updated jenkins.

在我的情况下,堆栈跟踪还显示了org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException[...]

In my case the stacktrace also showed a org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException[...]

Jenkins有一个安全插件,可以阻止Jenkinsfile中的某些方法调用.

Jenkins has a security plugin that blocks certain method calls in Jenkinsfile s.

允许这些有时无害的通话:

To allow these calls that sometimes are harmless:

  1. 转到: http://JENKINS_HOST/scriptApproval/(
  1. Go to: http://JENKINS_HOST/scriptApproval/ ( Official Documentation )
  2. Approve the action that has been denied in the Jenkinsfile
  3. Rerun the failed build to see Jenkinsfile work

这篇关于Jenkins声明性管道抛出org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException:未分类的getAt方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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