Skip to content

Instantly share code, notes, and snippets.

@esteele
Created February 22, 2017 02:14
Show Gist options
  • Save esteele/790ccb20bbaa3371eb53d8e64dd29a62 to your computer and use it in GitHub Desktop.
Save esteele/790ccb20bbaa3371eb53d8e64dd29a62 to your computer and use it in GitHub Desktop.
<body>
<h3>BUILD ${build.result}</h3>
<table>
<tr><td>URL</td><td><a href="${build.absoluteUrl}">${build.absoluteUrl}</a></td></tr>
<tr><td>Project:</td><td>${project.name}</td></tr>
<tr><td>Date:</td><td>${it.timestampString}</td></tr>
<tr><td>Duration:</td><td>${build.durationString}</td></tr>
<tr><td>Cause:</td><td><% build.causes.each() { cause -> %> ${cause.shortDescription} <% } %></td></tr>
</table>
<br />
<!-- CHANGE SET -->
<% def changeSet = build.changeSets
if(changeSet != null) {
def hadChanges = false %>
<h3>Changes</h3>
<table>
<% changeSet.each() { cs ->
hadChanges = true %>
<tr>
<td colspan="2" class="bg2">&nbsp;&nbsp;Revision <strong><%= cs.metaClass.hasProperty('commitId') ? cs.commitId : cs.metaClass.hasProperty('revision') ? cs.revision :
cs.metaClass.hasProperty('changeNumber') ? cs.changeNumber : "" %></strong> by
<strong><%= cs.author %>: </strong>
<strong>(${cs.msgAnnotated})</strong>
</td>
</tr>
<% cs.affectedFiles.each() { p -> %>
<tr>
<td width="10%">&nbsp;&nbsp;${p.editType.name}</td>
<td>${p.path}</td>
</tr>
<% }
}
if(!hadChanges) { %>
<tr><td colspan="2">No Changes</td></tr>
<% } %>
</table>
<br />
<% } %>
<!-- JUnit TEMPLATE -->
<% def junitResultList = it.JUnitTestResult
try {
def cucumberTestResultAction = it.getAction("org.jenkinsci.plugins.cucumber.jsontestsupport.CucumberTestResultAction")
junitResultList.add(cucumberTestResultAction.getResult())
} catch(e) {
//cucumberTestResultAction not exist in this build
}
if (junitResultList.size() > 0) { %>
<h3>${junitResultList.first().displayName}</h3>
<table width="100%">
<thead>
<tr>
<th>Name</th>
<th>Failed</th>
<th>Passed</th>
<th>Skipped</th>
<th>Total</th>
</tr>
</thead>
<% junitResultList.each{
junitResult -> %>
<% junitResult.getChildren().each { packageResult -> %>
<tr>
<td>${packageResult.getName()}</td>
<td>${packageResult.getFailCount()} test(s)</td>
<td>${packageResult.getPassCount()} test(s)</td>
<td>${packageResult.getSkipCount()} test(s)</td>
<td>${packageResult.getPassCount()+packageResult.getFailCount()+packageResult.getSkipCount()} test(s)</td>
</tr>
<tr bgcolor="white">
<td class="test_failed" colspan="5">
<ul>
<% packageResult.getFailedTests().each{ failed_test -> %>
<li>Failed: ${failed_test.getFullName()}</li>
<% } %>
</ul>
</td>
</tr>
<% }
} %>
</table>
<br />
<%
} %>
<!-- CONSOLE OUTPUT -->
<% if(build.result==hudson.model.Result.FAILURE) { %>
<h3>Console Output</h3>
<pre>
<% build.getLog(100).each() { line -> %>
<code>${org.apache.commons.lang.StringEscapeUtils.escapeHtml(line)}</code>
<% } %>
</pre>
<% } %>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment