`org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object`
IntermediateTroubleshootingJenkinsfile syntax, Groovy & CPS errors
Answer
Likely causes → Sandbox blocks a dynamic method call, often from calling a method on an untyped object in an untrusted library, or a misspelled method name that Groovy resolves dynamically.
Diagnose → Look at the line in the stack trace; check In-process Script Approval for the pending signature.
Fix → Fix the typo or type the variable. Do not approve invokeMethod generically; it allows calling any method. Move logic to a trusted library if it legitimately needs it.
Prevent → Unit test library code with JenkinsPipelineUnit and run test pipelines in the sandbox.
More on Jenkinsfile syntax, Groovy & CPS errors
`WorkflowScript: 1: Missing required section "agent" @ line 1, column 1.`Beginner`Unknown stage section "step". Starting with version 0.5, steps in a stage must be in a ‘steps’ block.`Beginner`java.lang.NoSuchMethodError: No such DSL method 'withSonarQubeEnv' found among steps [archive, bat, build, ...]`Beginner`java.io.NotSerializableException: java.util.regex.Matcher`Advanced`java.io.NotSerializableException: groovy.json.internal.LazyMap`Intermediate`groovy.lang.MissingPropertyException: No such property: IMAGE_TAG for class: groovy.lang.Binding`Beginner