tf-static-checks: introduce job
The proposed job (tf-static-checks) effectively superseed
'tf-a-static-checks.yaml', where besides the different names, the new
jobs is formatted similar as the recent migrated jobs and also
introduce a summary page as seen in [1].
This patch also fixes tf-main's static check job call, which now calls
the tf-static-checks job. Also, the static check code at
tf-a-builder is removed, leaving the latter job with the only purpose
of building (and nothing more).
[1] https://ci.staging.trustedfirmware.org/job/lsandov1-tf-static-checks/19/
Signed-off-by: Leonardo Sandoval <leonardo.sandoval@linaro.org>
Change-Id: Ic605ec8fe84445b080aa0dd38d4f85d289411656
diff --git a/tf-static-checks/postbuild.groovy b/tf-static-checks/postbuild.groovy
new file mode 100644
index 0000000..d88c9a1
--- /dev/null
+++ b/tf-static-checks/postbuild.groovy
@@ -0,0 +1,43 @@
+import hudson.model.*
+
+void log(msg) {
+ manager.listener.logger.println(msg)
+}
+
+def findRealUrl(url) {
+ def connection = url.openConnection()
+ connection.followRedirects = false
+ connection.requestMethod = "GET"
+ connection.connect()
+ if (connection.responseCode == 302) {
+ if (connection.headerFields.'Location') {
+ return findRealUrl(connection.headerFields.Location.first().toURL())
+ } else {
+ log('Failed to follow redirect')
+ }
+ }
+ return url
+}
+
+def artifact = "trusted-firmware-a/static-checks.log"
+def jobUrl = manager.hudson.getRootUrl() + "${manager.build.url}artifact/${artifact}"
+def url = new URL(jobUrl)
+def realUrl = findRealUrl(url)
+def connection = realUrl.openConnection()
+connection.requestMethod = "GET"
+if (connection.responseCode == 200) {
+ def summaryContent = connection.content.text
+ def summary = manager.createSummary("clipboard.gif")
+ def buildResult = manager.build.getResult()
+ def summaryHeader = ""
+ if (buildResult == Result.SUCCESS) {
+ summaryHeader = '<h1 style="color:green;">All good! Here\'s a summary of the static checks warnings (if any):</h1>'
+ } else {
+ summaryHeader = '<h1 style="color:red;">Some static checks failed!</h1>'
+ }
+ summary.appendText(summaryHeader, false)
+ summary.appendText("Here's a summary of the static check analysis :", false)
+ summary.appendText("<pre>" + summaryContent + "</pre>", false)
+} else {
+ log("Connection response code: ${connection.responseCode}")
+}