Jenkins的带有参数的JobDSL队列 [英] Jenkins' JobDSL Queue with Parameters
本文介绍了Jenkins的带有参数的JobDSL队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道您是否可以从具有参数的JobDSL中运行Jenkins的工作吗?
Does anyone know if you can run a Jenkins' job from JobDSL that has parameters?
我使用了队列 https://jenkinsci.github.io/job-dsl-plugin/#path/queue
但是根据文档,它仅接受字符串或Job对象.也许有一种方法可以处理Job对象,但是还不清楚.来自JobDSL文档:
But according to the docs, it only accepts a string or Job object. Maybe there is a way to do it with Job object, but its not clear. From JobDSL docs:
def example1 = job('example-1') {
displayName('first example')
}
queue(example1)
job('example-2') {
displayName('second example')
}
queue('example-2')
推荐答案
遇到同样的问题,并且无法在文档中找到答案,因此,我现在根据此
Have same problem and couldn't find an answer in docs so I'm now looking at using system groovy script as per this example.
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
I'm using Jenkins 2.116 and Groovy plugin 2.0
这篇关于Jenkins的带有参数的JobDSL队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文