blob: 5c5002e3751f3cfdf8c134dbf778ff7dec035b43 [file] [log] [blame]
Milosz Wasilewski10438582020-12-03 11:36:21 +00001import hudson.model.*
2
3def getUpstreamRoot(cause) {
4 causes = cause.getUpstreamCauses()
5 if (causes.size() > 0) {
6 if (causes[0] instanceof hudson.model.Cause.UpstreamCause) {
7 return getUpstreamRoot(causes[0])
8 }
9 }
10 return cause
11}
12
Paul Sokolovsky7c1186b2021-11-09 17:16:55 +030013def description = ""
14def rootUrl = manager.hudson.getRootUrl()
15
Milosz Wasilewski10438582020-12-03 11:36:21 +000016// Add a LAVA job link to the description
Paul Sokolovsky5aba7332023-03-16 18:18:05 +070017def matcher = manager.getLogMatcher("LAVA URL: (?<url>.*?) LAVA JOB ID: (?<jobid>\\d+)")
Milosz Wasilewski10438582020-12-03 11:36:21 +000018if (matcher?.matches()) {
19 def testJobId = matcher.group('jobid')
20 def testJobUrl = matcher.group('url')
Paul Sokolovskyc5189372023-12-30 14:17:11 +030021 description += "LAVA Job Id: <a href='${testJobUrl}'>${testJobId}</a>\n"
Leonardo Sandoval9f159802021-01-20 16:47:25 -060022
Leonardo Sandoval9f159802021-01-20 16:47:25 -060023 def lavaLogUrl = "${rootUrl}${manager.build.url}artifact/lava.log"
Paul Sokolovsky117c7c52024-01-04 12:20:18 +030024 description += " | <a href='${lavaLogUrl}'>log</a>\n"
Leonardo Sandovala8078d62021-02-11 16:29:25 -060025
Paul Sokolovsky2e533b42024-01-09 21:50:20 +030026 // Verify LAVA jobs results, all tests must pass, otherwise turn build into FAILED
Leonardo Sandovala8078d62021-02-11 16:29:25 -060027 def testMatcher = manager.getLogMatcher("LAVA JOB RESULT: (?<result>\\d+)")
28 if (testMatcher?.matches()) {
29 def testJobSuiteResult = testMatcher.group('result')
30 // result = 1 means lava job fails
31 if (testJobSuiteResult == "1") {
Paul Sokolovsky2e533b42024-01-09 21:50:20 +030032 manager.buildFailure()
Leonardo Sandovala8078d62021-02-11 16:29:25 -060033 }
34 }
Milosz Wasilewski10438582020-12-03 11:36:21 +000035}
Paul Sokolovsky7c1186b2021-11-09 17:16:55 +030036
Paul Sokolovsky63414352023-12-30 12:12:35 +030037// Add a TuxSuite job link to the description
38matcher = manager.getLogMatcher("TuxSuite test ID: (?<tuxid>[A-Za-z0-9]+)")
39if (matcher?.matches()) {
40 def tuxId = matcher.group('tuxid')
41 def abbrTuxId = "..." + tuxId.substring(19)
42 description += "Tux Id: <a href='https://tuxapi.tuxsuite.com/v1/groups/tfc/projects/ci/tests/${tuxId}'>${abbrTuxId}</a>\n"
Paul Sokolovskyfb8bb832024-01-06 00:02:39 +030043 description += " | <a href='https://storage.tuxsuite.com/public/tfc/ci/tests/${tuxId}/lava-logs.html'>log</a>\n"
Paul Sokolovsky63414352023-12-30 12:12:35 +030044}
45
46
Paul Sokolovsky7c1186b2021-11-09 17:16:55 +030047def causes = manager.build.getAction(hudson.model.CauseAction.class).getCauses()
48if (causes[0] instanceof hudson.model.Cause.UpstreamCause) {
49 def rootCause = getUpstreamRoot(causes[0])
50 def upstreamBuild = rootCause.upstreamBuild
51 def upstreamProject = rootCause.upstreamProject
52 def jobName = upstreamProject
53 def jobConfiguration = upstreamProject
54 def jobUrl = "${rootUrl}job/${upstreamProject}/${upstreamBuild}"
Paul Sokolovskyc5189372023-12-30 14:17:11 +030055 description += "<br>Top build: <a href='${jobUrl}'>${upstreamProject} #${upstreamBuild}</a>"
Paul Sokolovsky7c1186b2021-11-09 17:16:55 +030056}
57
58// Set accumulated description
59manager.build.setDescription(description)