如何使用 groovy 创建和配置新的 Jenkins 作业? [英] How create and configure a new Jenkins Job using groovy?
本文介绍了如何使用 groovy 创建和配置新的 Jenkins 作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
groovy 脚本的例子很多(http://scriptlerweb.appspot.com/catalog/list) 但是我没有发现创造新工作的例子.网上有没有一个很好的例子来说明应该如何做到这一点?
There are a lot of examples of groovy scripts (http://scriptlerweb.appspot.com/catalog/list) however I have found no examples of new job creation. Is there a good example online of how one should do this?
推荐答案
Create Pipeline script from SCM 作业:
Create Pipeline script from SCM job:
import hudson.plugins.git.*;
def scm = new GitSCM("git@github.com:dermeister0/Tests.git")
scm.branches = [new BranchSpec("*/develop")];
def flowDefinition = new org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition(scm, "Jenkinsfile")
def parent = Jenkins.instance
def job = new org.jenkinsci.plugins.workflow.job.WorkflowJob(parent, "New Job")
job.definition = flowDefinition
parent.reload()
另一个例子:https://github.com/linagora/james-jenkins/blob/master/create-dsl-job.groovy
这篇关于如何使用 groovy 创建和配置新的 Jenkins 作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文