Skip to content
Latchkey

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 trim

Common 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)

  1. Open Manage Jenkins > In-process Script Approval.
  2. Approve the exact signature listed in the error, after reviewing that it is safe.
Script Approval
// signature shown for approval
method java.lang.String trim

Move logic into a trusted shared library

  1. Put the Groovy in a global shared library loaded from a trusted source.
  2. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →