【发布时间】:2017-04-28 21:31:20
【问题描述】:
有谁知道如何在并行管道执行中捕获失败的作业编号,同时在作业失败的情况下仍然有 failFast 功能用于短路构建?我知道如果我在运行构建步骤时执行“propagate = false”,我可以让它工作,但这会杀死 failFast 功能,我需要它。
例如,下面是我的代码,我也想在 catch 块中获取变量 achild_job_info 的值。
build_jobs = [“Build_A”, “ Build_B”, “ Build_C”]
def build_job_to_number_mappings = [:]
// in this hashmap we'll place the jobs that we wish to run
def branches = [:]
def achild_job_info = ""
def abuild_number = ""
for (x in build_jobs) {
def abuild = x
branches[abuild] = {
stage(abuild){
retry(2) {
try {
achild_job_info = build job: abuild
echo “ achild_job_info” // —> this gives: org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper@232601dc
abuild_number = achild_job_info.getId()
build_job_to_number_mappings[abuild] = achild_job_info.getNumber()
} catch (err) {
echo “ achild_job_info: ${achild_job_info } “ // —> This comes empty. I want the runwrapper here as well, just like in the try block.
abuild_job_number = abuild_job_info.getId()
build_job_to_number_mappings[abuild] = achild_job_info.getNumber()
} // try-catch
} // stage
} // branches
} // for
branches.failFast = true
parallel branches
【问题讨论】: