I got some Jelly template working for this. First the jenkins file:

Make sure you collect your unit test results:
step([$class: 'JUnitResultArchiver', testResults: 'TestResult/*.xml']);


Then send the email:
emailext body: '${JELLY_SCRIPT,template="
${env.JENKINS_HOME}/email-templates/myTemplateFile.jelly"}', subject: 
email_subject, to: 'c...@bodycad.com', replyTo: 'jenk...@bodycad.com', 
mimeType: 'text/html'

Take car under Windows the '\\' is not supported into the template path and 
you need to flip them:
'${JELLY_SCRIPT,template="' + "${env.JENKINS_HOME}/email-templates/
myTemplateFile.jelly".replaceAll('[\\\\]','/') + '"}'

Here's the Jelly template that should be saved into Jenkins home folder 
under email-templates (I removed any style here to simplify the whole thing 
and removed other parts), you can modify the html to your code:

<?jelly escape-by-default='true'?>
<!DOCTYPE html [
<!ENTITY nbsp "&#38;#38;nbsp&#59;">
]>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d=
"jelly:define">
<!-- Header -->
<BODY>
<!-- Unit Test TEMPLATE -->
<TABLE width="100%">
 <TR>
 <TD colspan="2"><B>Unit Tests</B></TD>
 </TR>
 <j:forEach var="junitResult" items="${it.JUnitTestResult}">
 <j:forEach var="packageResult" items="${junitResult.getChildren()}">
 <TR>
 <TD>Tests Root Name</TD>
 <TD>${packageResult.getName()}</TD>
 </TR>
 <TR>
 <TD>Tests Counts</TD>
 <TD>
${packageResult.getPassCount()+packageResult.getFailCount()+packageResult.getSkipCount()}
</TD>
 </TR>
 <TR>
 <TD>Tests Pass</TD>
 <TD>${packageResult.getPassCount()}</TD>
 </TR>
 <TR>
 <TD>Tests Skip</TD>
 <TD>${packageResult.getSkipCount()}</TD>
 </TR>
 <TR>
 <TD>Tests Fail</TD>
 <TD>${packageResult.getFailCount()}</TD>
 </TR>
 <j:forEach var="failed_test" items="${packageResult.getFailedTests()}">
 <TR>
 <TD colspan="2"><B><li>Failed: ${failed_test.getFullName()} </li></B></TD>
 </TR>
 </j:forEach>
 </j:forEach> 
 </j:forEach>
</TABLE>
<BR/>
<!-- Footer -->
</BODY>
</j:jelly>


-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/35df7488-1e47-42f6-ae3b-9f4e88aa1242%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to