如何使用groovy创建和配置新的Jenkins作业? [英] How create and configure a new Jenkins Job using groovy?
问题描述
从SCM创建管道脚本 job:
import hudson.plugins.git。*;
def scm = new GitSCM(git@github.com:dermeister0 / Tests.git)
scm.branches = [new BranchSpec(* / develop)];
$ b $ def flowDefinition = new org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition(scm,Jenkinsfile)
$ b $ def parent = Jenkins.instance
def job = new org.jenkinsci.plugins.workflow.job.WorkflowJob(parent,New Job)
job.definition = flowDefinition
parent.reload()
另一个例子: There are a lot of examples of groovy scripts (http://scriptlerweb.appspot.com/catalog/list) no no example of new job creation. Create Pipeline script from SCM job: Another example: https://github.com/linagora/james-jenkins/blob/master/create-dsl-job.groovy 这篇关于如何使用groovy创建和配置新的Jenkins作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!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()