如何使用groovy创建和配置新的Jenkins作业? [英] How create and configure a new Jenkins Job using groovy?

查看:506
本文介绍了如何使用groovy创建和配置新的Jenkins作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多groovy脚本的例子( http://scriptlerweb.appspot.com/catalog/列表)no no new job creation。

解决方案

从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:

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()

Another example: https://github.com/linagora/james-jenkins/blob/master/create-dsl-job.groovy

这篇关于如何使用groovy创建和配置新的Jenkins作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆