从Jenkins中的公共共享库调用步骤时,如何处理RejectedAccessException?

时间:2020-08-03 07:30:17

标签: jenkins jenkins-groovy

我正在尝试为多个项目的Jenkins脚本中使用的通用步骤创建一个通用共享库。 我有一个步骤sendBuildInfoSlack,它先前调用了在同一JenkinsFile中定义的函数。我将其移至vars文件夹下公共共享库中的自己的步骤。

enter image description here

此文件的调用函数正在调用与直接在JenkinsFile中工作的函数相同的函数。但是,它给了我这个错误:

Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (org.jenkinsci.plugins.workflow.cps.CpsClosure2 sendBuildInfoSlack java.util.LinkedHashMap). Administrators can decide whether to approve or reject this signature.
Error when executing failure post condition:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (org.jenkinsci.plugins.workflow.cps.CpsClosure2 sendBuildInfoSlack java.util.LinkedHashMap)

我没想到会遇到此错误,特别是因为在声明Global Pipeline Libraries时,它明确指出这些库将受到信任,这意味着它们不受沙箱限制

此外,我还不清楚是哪种方法导致了此问题。

如果我不必将每个功能都列入白名单,我希望这样做,因为我希望该库能够涵盖更广泛使用的功能,而且我也没有将其列入白名单的权限。

请帮忙吗?

0 个答案:

没有答案