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}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)