Last active
February 8, 2022 12:17
-
-
Save nightspotlight/7cfa6af7c7989857f336f742cdcb443b to your computer and use it in GitHub Desktop.
Jelly template to display table with JUnit test results for Jenkins Email-ext plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?jelly escape-by-default='true'?> | |
<!DOCTYPE html [ | |
<!ENTITY nbsp "&#38;nbsp;"> | |
]> | |
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"> | |
<body> | |
<!-- GENERAL INFO --> | |
<table> | |
<tr> | |
<td align="right"> | |
<j:choose> | |
<j:when test="${build.result=='SUCCESS'}"> | |
<img src="${rooturl}static/e59dfe28/images/32x32/blue.gif" /> | |
</j:when> | |
<j:when test="${build.result=='FAILURE'}"> | |
<img src="${rooturl}static/e59dfe28/images/32x32/red.gif" /> | |
</j:when> | |
<j:otherwise> | |
<img src="${rooturl}static/e59dfe28/images/32x32/yellow.gif" /> | |
</j:otherwise> | |
</j:choose> | |
</td> | |
<td valign="center"><b style="font-size: 200%;">BUILD ${build.result}</b></td> | |
</tr> | |
<tr> | |
<td>Build URL:</td> | |
<td><a href="${rooturl}${build.url}">${rooturl}${build.url}</a></td> | |
</tr> | |
<tr> | |
<td>Project:</td> | |
<td>${project.name}</td> | |
</tr> | |
<tr> | |
<td>Date of build:</td> | |
<td>${it.timestampString}</td> | |
</tr> | |
<tr> | |
<td>Build duration:</td> | |
<td>${build.durationString}</td> | |
</tr> | |
</table> | |
<br /> | |
<!-- JUnit TEMPLATE --> | |
<j:set var="junitResultList" value="${it.JUnitTestResult}" /> | |
<j:if test="${junitResultList.isEmpty()!=true}"> | |
<div> | |
<h1><a href="${rooturl}${build.url}testReport">JUnit Tests</a></h1> | |
<table border="1"> | |
<tr> | |
<th>Package</th> | |
<th>Duration (sec)</th> | |
<th>Failed</th> | |
<th>Failed (diff)</th> | |
<th>Passed</th> | |
<th>Passed (diff)</th> | |
<th>Skipped</th> | |
<th>Skipped (diff)</th> | |
<th>Total</th> | |
<th>Total (diff)</th> | |
</tr> | |
<j:forEach var="junitResult" items="${it.JUnitTestResult}"> | |
<j:forEach var="packageResult" items="${junitResult.getChildren()}"> | |
<tr> | |
<td><tt>${packageResult.getName()}</tt></td> | |
<td>${packageResult.getDuration()}</td> | |
<td>${packageResult.getFailCount()}</td> | |
<td>${packageResult.getFailCount()-packageResult.previousResult.getFailCount()}</td> | |
<td>${packageResult.getPassCount()}</td> | |
<td>${packageResult.getPassCount()-packageResult.previousResult.getPassCount()}</td> | |
<td>${packageResult.getSkipCount()}</td> | |
<td>${packageResult.getSkipCount()-packageResult.previousResult.getSkipCount()}</td> | |
<td> | |
<b>${packageResult.getPassCount()+packageResult.getFailCount()+packageResult.getSkipCount()}</b> | |
</td> | |
<td> | |
<b>${packageResult.getPassCount()+packageResult.getFailCount()+packageResult.getSkipCount()-packageResult.previousResult.getPassCount()-packageResult.previousResult.getFailCount()-packageResult.previousResult.getSkipCount()}</b> | |
</td> | |
</tr> | |
<!-- | |
<j:forEach var="failed_test" items="${packageResult.getFailedTests()}"> | |
<tr> | |
<td colspan="5"><tt>${failed_test.getFullName()}</tt></td> | |
</tr> | |
</j:forEach> | |
--> | |
</j:forEach> | |
</j:forEach> | |
</table> | |
<br /> | |
</div> | |
</j:if> | |
</body> | |
</j:jelly> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@grayaii you need to copy this file into
$JENKINS_HOME/email-templates/template-name.jelly
. Then on job configuration page setDefault Content
field to${JELLY_SCRIPT,template="template-name"}
inEditable Email Notification section