Various fixes
* Retrieve build commands from build_manager
* fixing psa build dir
* Use different node labels for different builds
* Add script to download jenkins artifacts
* Verify status per stage
* Moving code to library
* Ability to comment on gerrit change
Change-Id: I390674b7ed6cfd20e4746a2d32e708fd6855857b
Signed-off-by: Dean Birch <dean.birch@arm.com>
diff --git a/src/org/trustedfirmware/Gerrit.groovy b/src/org/trustedfirmware/Gerrit.groovy
new file mode 100644
index 0000000..7addf0d
--- /dev/null
+++ b/src/org/trustedfirmware/Gerrit.groovy
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+package org.trustedfirmware
+
+def verifyStatus(value, verify_name, category) {
+ node("docker-amd64-xenial") {
+ cleanWs()
+ dir("tf-m-ci-scripts") {
+ git url: '$CI_SCRIPTS_REPO', branch: 'master', credentialsId: 'GIT_SSH_KEY'
+ }
+ verifyStatusInWorkspace(value, verify_name, category)
+ }
+}
+
+def verifyStatusInWorkspace(value, verify_name, category) {
+ withCredentials([usernamePassword(credentialsId: 'VERIFY_STATUS', passwordVariable: 'VERIFY_PASSWORD', usernameVariable: 'VERIFY_USER')]) {
+ sh("""
+ if [ -z "\$GERRIT_HOST" ] ; then
+ echo Not running for a Gerrit change, skipping vote.
+ exit 0
+ fi
+ if [ ! -d venv ] ; then
+ virtualenv -p \$(which python3) venv
+ fi
+ . venv/bin/activate
+ pip -q install requests
+ ./tf-m-ci-scripts/jenkins/verify.py --category ${category} --value ${value} --verify-name ${verify_name} --user \$VERIFY_USER
+ """)
+ }
+}
+
+def comment(comment) {
+ node("docker-amd64-xenial") {
+ cleanWs()
+ dir("tf-m-ci-scripts") {
+ git url: '$CI_SCRIPTS_REPO', branch: 'master', credentialsId: 'GIT_SSH_KEY'
+ }
+ commentInWorkspace(comment)
+ }
+}
+
+def commentInWorkspace(comment) {
+ withCredentials([usernamePassword(credentialsId: 'VERIFY_STATUS', passwordVariable: 'GERRIT_PASSWORD', usernameVariable: 'GERRIT_USER')]) {
+ sh("""
+ if [ -z "\$GERRIT_HOST" ] ; then
+ echo Not running for a Gerrit change, skipping.
+ exit 0
+ fi
+ if [ ! -d venv ] ; then
+ virtualenv -p \$(which python3) venv
+ fi
+ . venv/bin/activate
+ pip -q install requests
+ ./tf-m-ci-scripts/jenkins/comment.py --comment "${comment}" --user \$GERRIT_USER
+ """)
+ }
+}
diff --git a/src/org/trustedfirmware/Summary.groovy b/src/org/trustedfirmware/Summary.groovy
new file mode 100644
index 0000000..bb5b16d
--- /dev/null
+++ b/src/org/trustedfirmware/Summary.groovy
@@ -0,0 +1,68 @@
+//-------------------------------------------------------------------------------
+// Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+//
+// SPDX-License-Identifier: BSD-3-Clause
+//
+//-------------------------------------------------------------------------------
+
+package org.trustedfirmware;
+
+@NonCPS
+def getBuildCsv(results) {
+ def table = [:]
+ def projects = []
+ results.each { result ->
+ res = result.value[0]
+ config = result.value[1]
+ params = result.value[2]
+ if (params['BL2'] == 'True') {
+ bl2_string = 'BL2'
+ } else {
+ bl2_string = 'NOBL2'
+ }
+ row_string = "${params['TARGET_PLATFORM']}_${params['COMPILER']}_${params['CMAKE_BUILD_TYPE']}_${bl2_string}"
+ column_string = "${params['PROJ_CONFIG']}"
+ row = table[row_string]
+ if (row == null) {
+ row = [:]
+ }
+ row[column_string] = res.getResult()
+ table[row_string] = row
+ if(!projects.contains(params['PROJ_CONFIG'])) {
+ projects += params['PROJ_CONFIG']
+ }
+ }
+ header = []
+ header += "" // top left
+ header.addAll(projects)
+ header.sort { it.toLowerCase() }
+ csvContent = []
+ for (row in table) {
+ row_item = []
+ row_item += row.key
+ for (project in projects) {
+ result = table[row.key][project]
+ if (result == null) {
+ result = "N/A"
+ }
+ row_item += result
+ }
+ csvContent.add(row_item)
+ }
+ csvContent.sort { it[0].toLowerCase() }
+ csvContent.add(0, header)
+ return csvContent
+}
+
+@NonCPS
+def getLinks(results) {
+ linksContent = []
+ results.each { result ->
+ res = result.value[0]
+ config = result.value[1]
+ url = res.getAbsoluteUrl()
+ linksContent.add("${config}: <a href=\"${url}\">Job</a>/<a href=\"${url}/artifact/build.log/*view*/\">Logs</a>/<a href=\"${url}/artifact/\">Artifacts</a><br/>")
+ }
+ linksContent.sort()
+ return linksContent.join("\n")
+}