Jenkins Job DSL introduced Script Security in 1.6, this gives some builds the following error:
ERROR: Build step failed with exception
org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedUsageException: script not yet approved for use
We run Jenkins masters entirely through configuration using plugins.txt and a set of Groovy scripts to configure Jenkins, and do not allow any configuration to be done through the UI, so we also disable the ability to login as an admin.
How can we programmatically pre-approve scripts through the Jenkins groovy configuration?
Below is for approving two method with groovy on jenkins.
def scriptApproval = org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.get()
String[] signs = [
"method org.jenkinsci.plugins.workflow.steps.FlowInterruptedException getCauses",
"method org.jenkinsci.plugins.workflow.support.steps.input.Rejection getUser"
]
for( String sign : signs ) {
scriptApproval.approveSignature(sign)
}
scriptApproval.save()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With