Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Email-ext plugin default Jelly script shows all unit tests, not just failed ones

I am using the Email-ext plugin on Jenkins, and the default Jelly script ${JELLY_SCRIPT,template="html"}.

The template apparently outputs all unit tests in the email, not just the ones that have failed and made the build unstable. This is in itself a strange design decision since the important content gets lost, but is there an easy way to just output the failed tests in the email? I suppose I need to edit the default Jelly script template somewhere? Thanks!

like image 217
user1340582 Avatar asked Mar 21 '23 14:03

user1340582


2 Answers

${JELLY_SCRIPT,template="html"} in this script html refers to the file html.jelly. In Hudson this file is located in the path, HUDSON_HOME/plugins/email-ext/WEB-INF/classes/hudson/plugins/emailext/templates. You can create your own jelly file, say abc.jelly and use the script as ${JELLY_SCRIPT,template="abc"}

However, in Jenkin this jelly templates have been bundled to the jar email-ext.jar which is located in Jenkin_Home/plugins/email-ext/WEB-INF/lib. Open this Jar and update/create templates in the location /plugins/emailext/templates/ as per your requirement.

like image 160
Dipu H Avatar answered Apr 24 '23 10:04

Dipu H


There is an excellent example for how it is done using Jelly script in: https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/html-with-health-and-console.jelly -> Search for "JUnit TEMPLATE".

But more specifically it is done using

packageResult.getFailedTests()
like image 20
user3360767 Avatar answered Apr 24 '23 09:04

user3360767