我有一个小的 Jenkins 管道,它依次测试不同的 Postman 集合,然后我将单个 XML 文件合并为一个,然后将它们传递给 Jenkins。
管道片段:
...
steps {
script {
try {
sh '(cd ./integrativeTests/collections && rm -rf *.xml)'
sh '(cd ./integrativeTests/collections && npm run tests-all)'
sh '''
cd ./integrativeTests/collections
echo '<?xml version="1.0" encoding="UTF-8"?>' > newman_dev_results.xml
echo '<testsuites>' >> newman_dev_results.xml
for f in COLLECTION-*.xml
do
echo $(sed 1,$(expr $(grep -m1 -n "<testsuite" ${f} | cut -f1 -d:) - 1)d ${f}) >> newman_dev_results.xml
done
echo '</testsuites>' >> newman_dev_results.xml
cat newman_dev_results.xml
'''
sh '(cp ./integrativeTests/collections/newman_dev_results.xml ./newman_results.xml)'
currentBuild.result = 'SUCCESS'
} catch(Exception e) {
currentBuild.result = 'FAILURE'
}
junit 'newman_results.xml'
}
}
...
生成的 XML 如下所示:
但遗憾的是,我在 Jenkins 日志中收到了一个错误:
ERROR: None of the test reports contained any result
Finished: FAILURE
对于 Jenkins 具有多个集合的测试结果,正确的 xml 布局是什么,或者如何将多个测试结果传递给 Jenkins?