// Set description of all builds to result of failed tests def whichJob = "myJob"; def job = hudson.model.Hudson.instance.getItem(whichJob); def builds = job.getBuilds(); def bldRptStub = "<b>Failed Tests</b><ul>"; builds.each { build -> build.setDescription(''); if (build.testResultAction) { def bldRpt = bldRptStub; def setDescription = false; def tra = build.testResultAction; def childReports = tra.childReports; childReports.each { rpt -> def result = rpt.result; if (result.failedTests.size > 0) { setDescription = true; } result.failedTests.each { t -> if (t.name != '') { bldRpt += "<li>" + t.name + "</li>"; } } } bldRpt += "</ul>"; if (setDescription) { build.setDescription(bldRpt); } } }
Tuesday, June 24, 2014
Add failed test results to Jenkins build descriptions with Groovy
Subscribe to:
Posts (Atom)