问题描述
运行主项目后,每个下游项目都有测试结果,但最新聚合测试结果"是没有测试的.如何配置Jenkins让所有的测试结果显示在聚合列表中?
After running the main project, every downstream project has test result, but the "Latest Aggregated Test Result" is no tests. How to configure the Jenkins to make all the test results display in aggregated list?
推荐答案
聚合下游测试结果 不明显,也没有记录.以下步骤合成自How To Aggregate Downstream Test Results在哈德逊.
Aggregate downstream test results is not obvious, and not documented. The steps below are synthesized from How To Aggregate Downstream Test Results in Hudson.
要聚合,您需要在上游作业中存档工件,对工件进行指纹识别,然后将工件从上游作业传递到下游作业.用我自己的话来说:
To aggregate, you need to archive an artifact in the upstream job, fingerprint the artifact, and then pass the artifact from the upstream job to the downstream job. In my own words:
共享的指纹神器领带"作业放在一起,让上游作业看到下游的测试结果
为了说明这一点,我们可以在两个自由式作业 Job_A 和 Job_B 之间建立一个非常简单的流程.
To show this, we can make a very simple flow between two free-style jobs, Job_A and Job_B.
上游
Job_A 将运行并创建一个名为 some_file.txt 的工件.我们没有聚合 some_file.txt 的值/内容,但它需要被指纹识别,所以它不能为空.Job_A 然后将触发 Job_B 的构建.
Job_A will run and create an artifact named some_file.txt. We're not aggregating the value/contents of some_file.txt, but it needs to be finger-printed and so it cannot be empty. Job_A will then trigger a build of Job_B.
Job_A 的配置:
执行shell:
echo $(date) > some_file.txt
归档工件:
- 将要存档的文件设置为文件,some_file.text
- set Files to archive to the file, some_file.text
汇总下游测试结果:
- 选中自动聚合...选项
构建其他项目:
- 将要构建的项目设置为Job_B
记录文件指纹以跟踪使用情况:
- 将文件指纹设置为some_file.txt
下游
Job_B 将运行,从触发此运行的上游作业复制文件 some_file.txt,将一些模拟测试结果回显到 XML 文件,然后发布该 XML 结果文件.发布的结果将聚合回 Job_A.
Job_B will run, copy the file some_file.txt from the upstream job that triggered this run, echo out some mock test results to an XML file, then publish that XML result file. It's the published results that will get aggregated back into Job_A.
Job_B 的配置:
从另一个项目复制工件:
项目名称 | 工作_A |
哪个版本 | 触发此作业的上游构建 |
要复制的工件 | some_file.txt |
指纹文物 | ✔ |
执行shell:
XML_VAR='<testsuite tests="3">
<testcase classname="foo" name="ASuccessfulTest"/>
<testcase classname="foo" name="AnotherSuccessfulTest"/>
<testcase classname="foo" name="AFailingTest">
<failure type="ValueError">Not enough foo!!</failure>
</testcase>
</testsuite>'
echo $XML_VAR > results.xml
发布 JUnit 测试结果报告:
- 使用文件results.xml 设置测试报告XML
这应该足以让 Job_A 汇总 Job_B 的测试结果.我不确定是否有一种方法/插件可以根据下游结果更改 Job_A 的状态(例如,如果 Job_B 失败,则 Job_A 将追溯失败).
This should be sufficient to have Job_A aggregate Job_B's test results. I'm not sure if there's a way/plugin to change Job_A's status based on downstream results (like if Job_B failed, then Job_A would retroactively fail).
这篇关于下游的聚合结果在 Jenkins 中是“无测试"的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!