Scripts not permitted to use staticMethod in Extensible Choice System Groovy

5,376 views
Skip to first unread message

Victoria Kozel

unread,
Apr 20, 2017, 8:09:54 PM4/20/17
to Jenkins Users
Hello,

I am writing a simple groovy script to display role-based choices in the Extensible Choice. I get 

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod jenkins.model.Jenkins getInstance

when calling 

def authStrategy = Jenkins.instance.getAuthorizationStrategy()

I am not sure I understand the reason for this, but my question is - Is there a workaround for this error?

Thank you!!
Vicki

Victor Martinez

unread,
Apr 21, 2017, 3:35:55 AM4/21/17
to Jenkins Users
It seems the https://wiki.jenkins-ci.org/display/JENKINS/Script+Security+Plugin has been installed and enabled, therefore you need to whitelist those methods. Or even using the https://wiki.jenkins-ci.org/display/JENKINS/Permissive+Script+Security+Plugin plugin in case you would like to grant access to all those internal methods.

Cheers

Victoria Kozel

unread,
Apr 21, 2017, 5:20:15 PM4/21/17
to Jenkins Users
Victor,
 thank you so much for your help! I already had Script Security Plugin installed, and all the methods I tried to execute unsuccessfully were conveniently added in the Method Authorization queue! All i needed to do is just approved them. Worked like a charm. Thank you!!
Reply all
Reply to author
Forward
0 new messages