简体   繁体   English

如何以编程方式批准 Jenkins 系统 Groovy 脚本

[英]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.

相关问题 如何通过Jenkinsfile以编程方式批准Jenkins中的进程内脚本批准(脚本一) - How to approve the In-process script approvals in Jenkins programmatically through Jenkinsfile(scripted one) Jenkins-执行系统Groovy脚本 - Jenkins - execute system groovy script 如何使用 Jenkins Groovy 脚本中的凭据以编程方式调用 Git? - How to programmatically invoke Git with credentials in Jenkins Groovy script? Jenkins - 在哪里批准脚本 - Jenkins - where to approve the script 如何通过 groovy 脚本控制台批准来自 jenkinsfile 的脚本片段? - How to approve script snippets from a jenkinsfile via the groovy script console? 如何在jenkins文件系统上放置Email-Ext groovy脚本 - How to place Email-Ext groovy script on the jenkins file system 如何从“执行系统Groovy脚本”更改Jenkins环境变量 - How to change Jenkins environmental variable from 'Execute System Groovy Script' 在 Groovy 脚本中以编程方式配置 Jenkins 邮件程序插件 - Programmatically Configuring Jenkins Mailer Plugin in Groovy Script 如何从“执行系统Groovy脚本”中调用位于jenkins从属服务器中的批处理/常规脚本? - How to call batch/groovy script located in jenkins slave from “Execute system Groovy script”? jenkins 中执行 groovy 脚本和执行系统 ​​groovy 脚本的区别? - Difference between execute groovy script and the execute system groovy script in jenkins?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM