gpt4 book ai didi

jenkins 管道捕获失败的并行构建的 build_job 信息

转载 作者:行者123 更新时间:2023-12-02 18:28:08 25 4
gpt4 key购买 nike

有谁知道如何在并行管道执行中捕获失败作业的编号,同时仍然具有failFast功能,可以在作业失败时实现构建短路?我知道如果我在运行构建步骤时执行“propagate = false”,我可以让它工作,但这会杀死failFast功能,而我需要它。

例如,下面是我的代码,我也希望 catch block 内变量 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

最佳答案

我现在能找到的唯一方法是使用“异常字符串”的值并将其拆分以获取当前的内部版本号和名称。我不确定这是最可靠的方法,但目前有效。发布此回复是为了帮助其他人。

关于jenkins 管道捕获失败的并行构建的 build_job 信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43689169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com