2017-09-26 388 views
1

我在詹金斯定义的共享库:詹金斯声明管线抛出org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException:未分类getAt方法

import com.codependent.jenkins.pipelines.Utils 

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

如果我把这个从我的项目的Jenkinsfile这样它的工作原理OK:

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

但是如果我省略parethesis比如Groovy语法允许:

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

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

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) 
+0

我正面临类似的问题。你有没有找到解决方案?谢谢 – Matyas

+0

对不起,尚未解决。 – codependent

回答

1

我更新jenkins后有类似的问题。

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

原因

詹金斯有一个安全插件,阻止某些方法Jenkinsfile小号调用。

解决方案

为了让这些电话,有时是无害的:

  1. 转到:http://JENKINS_HOST/scriptApproval/Official Documentation
  2. 批准已在Jenkinsfile enter image description here
  3. 重新运行被拒绝的动作失败的构建看Jenkinsfile工作