How can I write a Jenkins email-ext template to display test results like the standard test report

Jon Freedman picture Jon Freedman · Jul 4, 2012 · Viewed 60.7k times · Source

I have tweaked the standard jelly template to display the current test results in a table, however I really want to be able to display diffs as seen in Jenkins own test results page.

For example:

JUnit Tests: 0 failures (±0) , 1 skipped (+1)

Package               Duration   Fail  (diff)  Skip  (diff)  Total  (diff)
foo.bar.baz              89 ms      0      0     1       +1     5       +2

Answer

malenkiy_scot picture malenkiy_scot · Jul 5, 2012

Write a Groovy template for Email Ext plugin instead of Jelly template. In Groovy template you'll have access to Build object for your build. You can then call getTestResultAction on it to obtain the AbstractTestResultAction for the build which you can then query for everything you need.

Here is a link to Jenkins Main Module API. A sample Groovy template for Ext Email plugin could be found in $JENKINS_HOME/plugins/email-ext/WEB-INF/classes/hudson/plugins/emailext/templates/groovy-html.template. More info on Groovy template/script usage can be found in Email Ext plugin documentation.