blob: 6cde8dd8a273005f82e3598492f6a9ca14cd9328 [file] [log] [blame]
Zachary Leaf09235922024-11-01 17:52:16 +00001import hudson.model.*
2
3void log(msg) {
4 manager.listener.logger.println(msg)
5}
6
7def findRealUrl(url) {
8 def connection = url.openConnection()
9 connection.followRedirects = false
10 connection.requestMethod = "GET"
11 connection.connect()
12 if (connection.responseCode == 302) {
13 if (connection.headerFields.'Location') {
14 return findRealUrl(connection.headerFields.Location.first().toURL())
15 } else {
16 log('Failed to follow redirect')
17 }
18 }
19 return url
20}
21
22def artifact = "trusted-firmware-a/next-checks.log"
23def jobUrl = manager.hudson.getRootUrl() + "${manager.build.url}artifact/${artifact}"
24def url = new URL(jobUrl)
25def realUrl = findRealUrl(url)
26def connection = realUrl.openConnection()
27connection.requestMethod = "GET"
28if (connection.responseCode == 200) {
29 def summaryContent = connection.content.text
30 def summary = manager.createSummary("clipboard.gif")
31 def buildResult = manager.build.getResult()
32 def summaryHeader = ""
33 if (buildResult == Result.SUCCESS) {
34 summaryHeader = '<h1 style="color:green;">All good! Here\'s a summary of the static checks warnings (if any):</h1>'
35 } else {
36 summaryHeader = '<h1 style="color:red;">Some static checks failed!</h1>'
37 }
38 summary.appendText(summaryHeader, false)
39 summary.appendText("Here's a summary of the static check analysis :", false)
40 summary.appendText("<pre>" + summaryContent + "</pre>", false)
41} else {
42 log("Connection response code: ${connection.responseCode}")
43}