栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

确定Jenkins声明式管道中的失败阶段

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

确定Jenkins声明式管道中的失败阶段

PipelineVisitor是一种很好的方法。但是,如果您只想查看错误,那么利用

FlowGraphTable
可能会更好。

以下内容提供了每个失败步骤的映射列表,并且还遍历了下游作业。我发现它非常有用。

您将要使用共享库来避免安全沙箱警告/批准

List<Map> getStepResults() {    def result = []    WorkflowRun build = currentBuild()    FlowGraphTable t = new FlowGraphTable(build.execution)    t.build()    for (def row in t.rows) {        if (row.node.error) { def nodeInfo = [         'name': "${row.node.displayName}",         'url': "${env.JENKINS_URL}${row.node.url}",         'error': "${row.node.error.error}",         'downstream': [:] ] if (row.node.getAction(LogStorageAction)) {     nodeInfo.url += 'log/' } for (def entry in getDownStreamJobAndBuildNumber(row.node)) {     nodeInfo.downstream["${entry.key}-${entry.value}"] = getStepResults(entry.key, entry.value) } result << nodeInfo        }    }    log(result)    return result}Map getDownStreamJobAndBuildNumber(def node) {    Map downStreamJobsAndBuilds = [:]    for (def action in node.getActions(NodeDownstreamBuildAction)) {        def result = (action.link =~ /.*/(?!/)(.*)/runs/(.*)//).findAll()        if (result) { downStreamJobsAndBuilds[result[0][1]] = result[0][2]        }    }    return downStreamJobsAndBuilds}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/418934.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号