Jenkins "Scripts not permitted to use method" Sandbox Error
The Groovy sandbox blocked a method call your pipeline made because the script-security plugin has not approved that signature.
What this error means
A stage fails with "Scripts not permitted to use method ..." naming a class and method. The build otherwise runs and the same call fails until an admin approves it.
jenkins
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException:
Scripts not permitted to use method java.lang.String trimCommon causes
Sandboxed pipeline calls an unapproved signature
In-sandbox Groovy may only call signatures on the script-approval allowlist; anything else is rejected.
Use of reflection or system APIs
Calls into JVM internals or file/system APIs are blocked by default and require explicit approval.
How to fix it
Approve the signature (admin)
- Open Manage Jenkins > In-process Script Approval.
- Approve the exact signature listed in the error, after reviewing that it is safe.
Script Approval
// signature shown for approval
method java.lang.String trimMove logic into a trusted shared library
- Put the Groovy in a global shared library loaded from a trusted source.
- Trusted-library code runs outside the sandbox and does not need per-signature approval.
How to prevent it
- Keep complex Groovy in a reviewed shared library instead of inline sandboxed scripts, which avoids accumulating ad-hoc approvals.
Related guides
Jenkins "MissingPropertyException: No such property" ErrorFix the Jenkins groovy.lang.MissingPropertyException "No such property" error caused by an undefined variable…
Jenkins "WorkflowScript: unexpected token" Jenkinsfile Parse ErrorFix the Jenkins "WorkflowScript: N: unexpected token" Groovy parse error that fails a Jenkinsfile before any…
Jenkins "No such DSL method found among steps" Pipeline ErrorFix the Jenkins "No such DSL method X found among steps" error caused by a missing plugin, a misspelled step…