Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 399
Jon Freedman Avatar asked Jul 04 '12 16:07

Jon Freedman


People also ask

How do I email a Jenkins report?

Step 1 - Installing Email Extension Plugin. Open Jenkins using the following URL: http://localhost:8080/ on any browser (in this tutorial port 8071 is used). Click on Manage Jenkins. Click on Manage Plugins. Select Email Extension and Email Extension Template Plugin and click Install Without Restart.

What is extended email notification in Jenkins?

This plugin allows you to configure every aspect of email notifications. You can customize when an email is sent, who should receive it, and what the email says.

How do I change my email template in Jenkins?

Added script under *Jenkins -> Manage Jenkins -> Editable Email Notification Templates-> Add New Template* and then under "Default Content" section, we added default groovy scripts (for example: groovy-html. template - Copy paste content). Save. Now under project job, under Post-build section we selected same template.


1 Answers

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.

like image 176
malenkiy_scot Avatar answered Sep 19 '22 01:09

malenkiy_scot