有没有人知道如何在并行管道执行中捕获失败的作业号码,同时还有failFast功能在作业失败的情况下用于短路构建?我知道如果我做的话,我可以帮助它...#34; 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
答案 0 :(得分:2)
我现在唯一能找到的方法是使用'异常字符串'并将其拆分以获取当前的内部版本号和名称。我不确定这是最强大的方法,但现在可以使用。发布此回复以帮助他人。