简体   繁体   中英

Groovy - Jenkins pipeline -

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException:

Scripts not permitted to use staticMethod {class_namespace}.{class_name} get{variableName} at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectStaticMethod(StaticWhitelist.java:189)

The code looks something like this - with a static variable declaration

class DummyClass
{
  static final String variableName='anysortavalue'
}
  • This script was running with the Groovy Sandbox
  • Despite this, it appears that a shortcut is being used - disallowing the declaration of all static variables.
  • Fix: change the declaration to instance variable:
class DummyClass
{
  final String variableName='anysortavalue'
}

further reading : https://jenkins.io/doc/book/managing/script-approval/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM