blob: 9a8089de0222fe7c5a3c99b8837e9568b3407839 [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
13// Add a LAVA job link to the description
14def matcher = manager.getLogMatcher("TEST JOB URL: (?<url>.*?) TEST JOB ID: (?<jobid>\\d+)")
15if (matcher?.matches()) {
16 def testJobId = matcher.group('jobid')
17 def testJobUrl = matcher.group('url')
Fathi Boudradb7baca2021-01-26 21:38:17 +010018 def testDescription = "&nbsp;Test Job Id: <a href='${testJobUrl}'>${testJobId}</a>"
Leonardo Sandoval9f159802021-01-20 16:47:25 -060019
20 def rootUrl = manager.hudson.getRootUrl()
21 def lavaLogUrl = "${rootUrl}${manager.build.url}artifact/lava.log"
22 def lavaDescription = "<br >&nbsp;LAVA log: <a href='${lavaLogUrl}'>lava.log</a>"
Milosz Wasilewski10438582020-12-03 11:36:21 +000023
24 def causes = manager.build.getAction(hudson.model.CauseAction.class).getCauses()
25 if (causes[0] instanceof hudson.model.Cause.UpstreamCause) {
26 def rootCause = getUpstreamRoot(causes[0])
27 def upstreamBuild = rootCause.upstreamBuild
28 def upstreamProject = rootCause.upstreamProject
29 def jobName = upstreamProject
30 def jobConfiguration = upstreamProject
Leonardo Sandoval9f159802021-01-20 16:47:25 -060031 def jobUrl = "${rootUrl}job/${upstreamProject}/${upstreamBuild}"
Milosz Wasilewski10438582020-12-03 11:36:21 +000032 def jobDescription = "<br>&nbsp;Build <a href='${jobUrl}'>${upstreamProject} #${upstreamBuild}</a>"
33
Leonardo Sandoval9f159802021-01-20 16:47:25 -060034 manager.build.setDescription(testDescription + lavaDescription + jobDescription)
Milosz Wasilewski10438582020-12-03 11:36:21 +000035 }
36}