Guest User

Untitled

a guest
Feb 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.22 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <head>
  3. <title>Build report</title>
  4. <style type="text/css">
  5. body
  6. {
  7. margin: 0px;
  8. padding: 15px;
  9. }
  10.  
  11. body, td, th
  12. {
  13. font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Tahoma, sans-serif;
  14. font-size: 10pt;
  15. }
  16.  
  17. th
  18. {
  19. text-align: left;
  20. }
  21.  
  22. h1
  23. {
  24. margin-top: 0px;
  25. }
  26.  
  27. li
  28. {
  29. line-height: 15pt;
  30. }
  31.  
  32. .change-add
  33. {
  34. color: #272;
  35. }
  36.  
  37. .change-delete
  38. {
  39. color: #722;
  40. }
  41.  
  42. .change-edit
  43. {
  44. color: #247;
  45. }
  46.  
  47. .grayed
  48. {
  49. color: #AAA;
  50. }
  51.  
  52. .error
  53. {
  54. color: #A33;
  55. }
  56.  
  57. pre.console
  58. {
  59. color: #333;
  60. font-family: "Lucida Console", "Courier New";
  61. padding: 5px;
  62. line-height: 15px;
  63. background-color: #EEE;
  64. border: 1px solid #DDD;
  65. }
  66. </style>
  67. </head>
  68. <body>
  69.  
  70. <h1>Build ${build.result}</h1>
  71. <table>
  72. <tr><th>Build URL:</th><td><a href="${rooturl}${build.url}">${rooturl}${build.url}</a></td></tr>
  73. <tr><th>Project:</th><td>${project.name}</td></tr>
  74. <tr><th>Date of build:</th><td>${it.timestampString}</td></tr>
  75. <tr><th>Build duration:</th><td>${build.durationString}</td></tr>
  76. </table>
  77.  
  78. <!-- ARTIFACTS -->
  79. <% artifacts = build.artifacts
  80. if (artifacts != null && artifacts.size() > 0) { %>
  81. <h2>Build artifacts</h2>
  82. <ul>
  83. <% artifacts.each() { f -> %>
  84. <li><a href="${rooturl}${build.url}artifact/${f}">${f}</a></li>
  85. <% } %>
  86. </ul>
  87. <% } %>
  88.  
  89. <%
  90. //testResult = build.testResultAction
  91. testResult = build.getAction(hudson.tasks.junit.TestResultAction.class)
  92.  
  93. if (testResult) {
  94. jobName = build.parent.name
  95. rootUrl = hudson.model.Hudson.instance.rootUrl
  96. testResultsUrl = "${rootUrl}${build.url}testReport/"
  97.  
  98. lastBuildSuccessRate = String.format("%.2f", (testResult.totalCount - testResult.result.failCount) * 100f / testResult.totalCount)
  99. lastBuildDuration = String.format("%.2f", testResult.result.duration)
  100.  
  101. startedPassing = []
  102. startedFailing = []
  103. failing = []
  104.  
  105. previousFailedTestCases = new HashSet()
  106. currentFailedTestCase = new HashSet()
  107.  
  108. //if (build.previousBuild?.testResultAction) {
  109. // build.previousBuild.testResultAction.failedTests.each {
  110. // previousFailedTestCases << it.simpleName + "." + it.safeName
  111. // }
  112. //}
  113.  
  114. testResult.failedTests.each { tr ->
  115. packageName = tr.packageName
  116. className = tr.simpleName
  117. testName = tr.safeName
  118. displayName = className + "." + testName
  119.  
  120. currentFailedTestCase << displayName
  121. url = "${rootUrl}${build.url}testReport/$packageName/$className/$testName"
  122. if (tr.age == 1) {
  123. startedFailing << [displayName: displayName, url: url, age: 1]
  124. } else {
  125. failing << [displayName: displayName, url: url, age: tr.age]
  126. }
  127. }
  128.  
  129. startedPassing = previousFailedTestCases - currentFailedTestCase
  130. startedFailing = startedFailing.sort {it.displayName}
  131. failing = failing.sort {it.displayName}
  132. startedPassing = startedPassing.sort()
  133. %>
  134.  
  135. <% if (startedPassing) { %>
  136. <h3>Following tests started passing. Good work!</h3>
  137. <ul>
  138. <% startedPassing.each { %>
  139. <li>${it}</li>
  140. <% } %>
  141. </ul>
  142. <% } %>
  143.  
  144. <% if (startedFailing) { %>
  145. <h3>Following tests started FAILING. Have the last change caused it!!</h3>
  146. <ul>
  147. <% startedFailing.each { %>
  148. <li><a href="${it.url}">${it.displayName}</a></li>
  149. <% } %>
  150. </ul>
  151. <% } %>
  152.  
  153. <% if (failing) { %>
  154. <h3>Following tests are conitnuously failing. Someone should look into it!!!</h3>
  155. <ul>
  156. <% failing.each { %>
  157. <li><a href="${it.url}">${it.displayName}</a> (Failing since ${it.age} runs)</li>
  158. <% } %>
  159. </ul>
  160. <% } %>
  161.  
  162. <% } %>
  163.  
  164. <%
  165. lastAllureReportBuildAction = build.getAction(ru.yandex.qatools.allure.jenkins.AllureReportBuildAction.class)
  166. lastAllureBuildAction = build.getAction(ru.yandex.qatools.allure.jenkins.AllureBuildAction.class)
  167.  
  168. if (lastAllureReportBuildAction) {
  169. allureResultsUrl = "${rootUrl}${build.url}allure"
  170.  
  171. allureLastBuildSuccessRate = String.format("%.2f", (lastAllureReportBuildAction.getTotalCount() - lastAllureReportBuildAction.getFailedCount()) * 100f / lastAllureReportBuildAction.getTotalCount())
  172. }
  173. %>
  174.  
  175. <% if (lastAllureReportBuildAction) { %>
  176. <h2>Allure Results</h2>
  177. <ul>
  178. <li>Total Allure tests ran: <a href="${allureResultsUrl}">${lastAllureReportBuildAction.getTotalCount()}</a></li>
  179. <li>Success rate: ${allureLastBuildSuccessRate}% </li>
  180. <img lazymap="${allureResultsUrl}/graphMap" src="${allureResultsUrl}/graph" alt="Allure results trend"/>
  181. </ul>
  182. <% } %>
  183.  
  184. <!-- BUILD FAILURE REASONS -->
  185. <% if (build.result == hudson.model.Result.FAILURE) {
  186. log = build.getLog(100).join("\n")
  187. warningsResultActions = build.actions.findAll { it.class.simpleName == "WarningsResultAction" }
  188.  
  189. if (warningsResultActions.size() > 0) { %>
  190. <h2>Build errors</h2>
  191. <ul>
  192. <% warningsResultActions.each {
  193. newWarnings = it.result.newWarnings
  194. if (newWarnings.size() > 0) {
  195. newWarnings.each {
  196. if (it.priority.toString() == "HIGH") { %>
  197. <li class="error">In <b>${it.fileName}</b> at line ${it.primaryLineNumber}: ${it.message}</li>
  198. <% }} %>
  199. <% }} %>
  200. </ul>
  201. <% } %>
  202.  
  203. <h2>Console output</h2>
  204. <pre class="console">${log}</pre>
  205.  
  206. <% } %>
  207.  
  208. </body>
Add Comment
Please, Sign In to add comment