Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Scripts not permitted to use staticMethod..." but there are no pending signature approvals

In my pipeline script, I get the error org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods drop java.util.List int.

So far, so good. But when I go to the ScriptApproval page, there are no pending signature approvals.

The odd thing is that on a different Jenkins system, when I ran the same command, it added it to the pending script approvals, and I was able to use it just fine.

Is there a way to either

  1. force it to add that function as a pending script approval?
  2. manually add it to the list of approved scripts?
like image 514
PortMan Avatar asked Apr 12 '18 15:04

PortMan


2 Answers

I have faced the similar problem, Jenkins did not add any static method to script approval page.

Think it was a some kind of bug with Jenkins and security plugin, because I have never met this behavior before. As workaround I had to manual execute the next script in "Script Console" page on https://JENKINS_URL/script

def scriptApproval = org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.get()
scriptApproval.approveSignature("staticMethod jenkins.model.Jenkins getInstance")
scriptApproval.save()
like image 51
Pavel Kovalev Avatar answered Sep 21 '22 18:09

Pavel Kovalev


I had the same, is your pipeline multibranch?
Mine was and I solved it by doing the following:
Add the method invocation 'org.codehaus.groovy.runtime.DefaultGroovyMethods drop' in another pipeline that is NON multibranched, if you dont have any just create a dummy one.
Run the pipeline, it will now appear under the script approval section.
Apparently this bug only affects multibranch pipelines. Hope it can still be useful.

like image 33
JBoy Avatar answered Sep 22 '22 18:09

JBoy