小编典典

Jenkins的带有参数的JobDSL队列

jenkins

有人知道您是否可以从具有参数的JobDSL中运行Jenkins的工作吗?

我已经使用了队列https://jenkinsci.github.io/job-dsl-
plugin/#path/queue

但是根据文档,它仅接受字符串或Job对象。也许有一种方法可以对Job对象进行处理,但是还不清楚。从JobDSL文档:

def example1 = job('example-1') {
   displayName('first example')
}

queue(example1)

job('example-2') {
    displayName('second example')
}

queue('example-2')

阅读 442

收藏
2020-07-25

共1个答案

小编典典

有同样的问题并且在文档中找不到答案,所以我现在按照这个例子使用系统groovy脚本。

def job = Hudson.instance.getJob('MyJobName')
def anotherBuild
try {
    def params = [
      new StringParameterValue('FOO', foo)
    ]
    def future = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))
    println "Waiting for the completion of " + HyperlinkNote.encodeTo('/' + job.url, job.fullDisplayName)
    anotherBuild = future.get()
} catch (CancellationException x) {
    throw new AbortException("${job.fullDisplayName} aborted.")
}

我正在使用Jenkins 2.116和Groovy插件2.0

2020-07-25