如何使用groovy创建和配置新的Jenkins作业?
发布时间:2020-12-14 16:33:40 所属栏目:大数据 来源:网络整理
导读:有很多groovy脚本的例子( http://scriptlerweb.appspot.com/catalog/list),没有创造新工作的例子. 解决方法 从SCM作业创建管道脚本: import hudson.plugins.git.*;def scm = new GitSCM("git@github.com:dermeister0/Tests.git")scm.branches = [new Branch
有很多groovy脚本的例子(
http://scriptlerweb.appspot.com/catalog/list),没有创造新工作的例子.
解决方法
从SCM作业创建管道脚本:
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |