[英]How to programmatically approve Jenkins System Groovy Script
Jenkins Job DSL introduced Script Security in 1.6, this gives some builds the following error: Jenkins Job DSL 在 1.6 中引入了 Script Security,这给一些构建带来了以下错误:
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.我们完全通过使用 plugins.txt 和一组 Groovy 脚本的配置来运行 Jenkins 主站来配置 Jenkins,并且不允许通过 UI 完成任何配置,因此我们也禁用了以管理员身份登录的功能。
How can we programmatically pre-approve scripts through the Jenkins groovy configuration?我们如何通过 Jenkins groovy 配置以编程方式预先批准脚本?
Below is for approving two method with groovy on jenkins.下面是在 jenkins 上用 groovy 批准两种方法。
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.