A Jenkins pipeline can publish XUnit test results as a step in a Jenkinsfile. Being unable to find any online documentation for the XUnitBuilder CheckType parameters, I dug into the code myself to find the answers.
Here’s a full XUnitBuilder stanza like that generated from the Jenkins Pipeline Snippet Generator (with the lines wrapped):
step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1, thresholds: [ [$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: ''], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: ''] ], tools: [ [$class: 'CheckType', deleteOutputFiles: false, failIfNotNew: false, pattern: '**/unittests.xml', skipNoTestFiles: false, stopProcessingIfError: true] ] ])
Here are the CheckType parameters and what they mean:
- deleteOutputFiles – If true, the output files are deleted after being processed. If false they are left in-place. Default: false.
- failIfNotNew – If true and files match the pattern but were not updated in the last build, the check fails. This helps ensure that all tests were run. Default: false.
- pattern – File pattern that identifies XUnit-formatted output.
- skipNoTestFiles – If true and no test files matching pattern are found, the check is skipped. If false and no tests are found the check fails. Default: false.
- stopProcessingIfError – If true, any error (such as an empty result file) will stop any further processing. If false, errors will be reported but processing will continue. Default: true.
Note that you can get by with a much smaller step stanza by just including values that differ from the defaults, eg:
step([$class: 'XUnitBuilder', tools: [ [$class: 'CheckType', pattern: '**/unittests.xml', skipNoTestFiles: true] ] ])