有很多 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
关于groovy - 如何使用 groovy 创建和配置新的 Jenkins 作业?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16963309/