有什么方法可以获取在职位脚本中在詹金斯中执行(或通过)的测试数量( 例如,将该数量发送到Github Status API )?
我没有任何直接从Publish JUnit test result reportJenkins插件访问这些数字的方法。
Publish JUnit test result report
但是,在成功解析JUnit XML之后,您始终可以使用/解析从Jenkins REST API中获取的xml或json:
http://<jenkinsHost>/job/<YourJobName>/<JobID>/testReport/api/json?pretty=true 要么
http://<jenkinsHost>/job/<YourJobName>/<JobID>/testReport/api/json?pretty=true
使它更通用: http://<jenkinsHost>/job/<YourJobName>/lastSuccessfulBuild/testReport/api/json?pretty=true
http://<jenkinsHost>/job/<YourJobName>/lastSuccessfulBuild/testReport/api/json?pretty=true
对于JSON输出:
{ "duration" : 6109.1104, "failCount" : 0, "passCount" : 4389, "skipCount" : 0, "suites" : [ { "cases" : [ { ... } ], "duration" : 0.012, "id" : null, "name" : "EventTest", "stderr" : null, "stdout" : null, "timestamp" : null } ] }
http://<jenkinsInstanceHost>/job/<YourJobName>/<JobID>/testReport/api/xml
用于XML输出:
<testResult> <duration>6109.1104</duration> <failCount>0</failCount> <passCount>4389</passCount> <skipCount>0</skipCount> <suite> <case> <age>0</age> <className> ... </className> <duration>0.012</duration> <failedSince>0</failedSince> <name>Loop</name> <skipped>false</skipped> <status>PASSED</status> </case> <duration>0.012</duration> <name>EventTest</name> </suite> </testResult>