While trying to publish test results in Jenkins CI via the xUnit plugin, I’ve set up the Post-build Actions section in Jenkins according to what the nosetests documentation suggests, that is, to “tick the box named “Publish JUnit test result report”” and referenced the correct file.
However, I was repeatedly stumbling upon an error:
WARNING: The file '/var/lib/jenkins/workspace/Project/nosetests.xml' is an invalid file. WARNING: At line 1 of file:/var/lib/jenkins/workspace/Project/nosetests.xml:cvc-complex-type.3.2.2: Attribute 'skip' is not allowed to appear in element 'testsuite'. ERROR: The result file '/var/lib/jenkins/workspace/Project/nosetests.xml' for the metric 'JUnit' is not valid. The result file has been skipped.
Turns out, my nosetests.xml file does indeed contain the
skip attribute. And that’s also in line with the example in the official documentation.
Much to my surprise, though, running a few web searches made me realize there aren’t many other users of Jenkins + xUnit plugin + nosetests who have the same problem.
To fix this, it looked like I had to write my one XLS file. All you need to do is create two templates, one matching the “skip” attribute, and the other matching everything else.
The “skip”-matching template will simply get rid of the attribute altogether. The other will pass everything else as it is.
By taking cue from this StackOverflow answer, the result is as follows:
Save it as nosetests.xsl. Now, armed with your shiny XSL file, put it in the
$JENKINS_HOME/userContent directory, say in
In the job config page, under the Post-Build Actions section, change the type from JUnit to Custom, and provide a reference to the XSD file you’ve created, in the form of
Save, run, and happily enjoy your test results!