Skip to content

Instantly share code, notes, and snippets.

@brokenthumbs
Last active March 21, 2016 20:02
Show Gist options
  • Save brokenthumbs/8922380 to your computer and use it in GitHub Desktop.
Save brokenthumbs/8922380 to your computer and use it in GitHub Desktop.
channel = manager.build.workspace.channel;
workspace = manager.build.workspace.toString();
def readFromFile( file ) {
return new hudson.FilePath( channel, workspace + "/" + file ).readToString()
}
failedTests = manager.build.testResultAction.getFailedTests()
for ( int i = 0; i < failedTests.size() ; i++ ) {
failedTest = failedTests.get( i )
testClass = failedTest.getClassName()
testExample = failedTest.getName()
testDirectory = "output/html/" + testClass + "/" + testExample
image = manager.build.getEnvironment(manager.listener)['BUILD_URL'] + "artifact/" + testDirectory + "/screenshot.png"
image_src = image
image_src = image_src.replaceAll( '\\[', "%5B" )
image_src = image_src.replaceAll( '\\]', "%5D" )
image_src = image_src.replaceAll( '\\>', "%3E" )
image_src = image_src.replaceAll( ' ', "%20" )
output_html = ""
output_html += "<div class=\"selenium-test-result\">"
output_html += readFromFile( testDirectory + "/result.html" )
output_html += "<h3>Screenshot</h3>"
output_html += "<a href=\"" + image + "\"><img style=\"width:50%;height:50%;\" src=\"" + image_src + "\"></a><br><br>"
output_html += "<a href=\"" + image + "\">" + image + "</a> "
output_html += "</div>"
failedTest.description = output_html
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment