我正在尝试在Jenkins中创建一个流水线(pipeline),可以在不同的节点(agents)上多次触发同一个作业(job)。
我已经在Jenkins中配置了名为“Create_Invoice”的作业,选择了“(Execute Concurrent builds if necessary)”选项。如果我点击10次“构建(Build)”按钮,它将在不同的(可用)代理程序/节点上运行10次。
与其手动点击10次,我想创建一个并行流水线(parallel pipeline)。
我创建了如下内容——它触发了该作业,但只运行了一次。 我错过了什么或者从流水线(pipeline)中是否有可能同时多次触发同一个测试(test)?
提前感谢你。
node {
def notifyBuild = { String buildStatus ->
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESSFUL'
// Default values
def tasks = [:]
try {
tasks["Test-1"] = {
stage ("Test-1") {
b = build(job: "Create_Invoice", propagate: false).result
}
}
tasks["Test-2"] = {
stage ("Test-2") {
b = build(job: "Create_Invoice", propagate: false).result
}
}
parallel tasks
} catch (e) {
// If there was an exception thrown, the build failed
currentBuild.result = "FAILED"
throw e
}
finally {
notifyBuild(currentBuild.result)
}
}
}