From c45278654b80b95b71cba9b840987e84534974a2 Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Sun, 5 Jan 2020 18:00:13 +0000 Subject: [PATCH 1/3] Remove unused createCheckPayload() method The Checks API integration is now delegated to the gerrit-code-review plugin and thus the createCheckPayload() method isn't needed anymore. Change-Id: I2479ec551c4dae85b83c504413e77405c327bd9f --- Jenkinsfile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2b5414a649..eb35f41af4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -74,14 +74,6 @@ class GerritCheck { return "FAILED" } } - - def createCheckPayload() { - return JsonOutput.toJson([ - checker_uuid: uuid, - state: getCheckResultFromBuild(), - url: "${build.url}consoleText" - ]) - } } def hasChangeNumber() { From 8ffcf65ba6068e5386b432495773aad74028ff8d Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Sun, 5 Jan 2020 21:56:09 +0000 Subject: [PATCH 2/3] Link checker result to the proper console URL Point each individual checker to its associated sub-job's console URL. Change-Id: Ifbdb646ac0fec94420a68760c4847d52f97690ba --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index eb35f41af4..53a1cc73fe 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -54,11 +54,13 @@ class Builds { class GerritCheck { String uuid Build build + String consoleUrl GerritCheck(name, build) { this.uuid = "gerritforge:" + name.replaceAll("(bazel/)", "") + Globals.gerritRepositoryNameSha1Suffix this.build = build + this.consoleUrl = "${build.url}console" } def getCheckResultFromBuild() { @@ -81,7 +83,7 @@ def hasChangeNumber() { } def postCheck(check) { - gerritCheck(checks: [ "${check.uuid}" : "${check.getCheckResultFromBuild()}" ]) + gerritCheck(checks: [ "${check.uuid}" : "${check.getCheckResultFromBuild()}" ], url: "${check.consoleUrl}") } def queryChangedFiles(url, changeNum, sha1) { From cb5bdf7ebb11b8d44a825eae3d244766bbe313ff Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Sun, 5 Jan 2020 18:05:04 +0000 Subject: [PATCH 3/3] Reduce change spamming from CI Now that the checks integration is reliable and clear enough in terms of messaging, the extra spamming from the CI on the change log can be reduced to a minimum avoiding the redundant feedback on validation and build logs URLs. Change-Id: Idd23d088c5238ecdcd1106a378cf65e198b77782 --- Jenkinsfile | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 53a1cc73fe..085cc65748 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,6 @@ class Globals { static final long curlTimeout = 10000 static final int waitForResultTimeout = 10000 static final String gerritRepositoryNameSha1Suffix = "-a6a0e4682515f3521897c5f950d1394f4619d928" - static final resTicks = [ 'ABORTED':'\u26aa', 'SUCCESS':'\u2705', 'FAILURE':'\u274c' ] } class Change { @@ -241,25 +240,6 @@ def findCodestyleFilesInLog(build) { return codeStyleFiles } -def createCodeStyleMsgBody(build, label) { - def codeStyleFiles = findCodestyleFilesInLog(build) - def formattingMsg = label < 0 ? ('The following files need formatting:\n ' + - codeStyleFiles.join('\n ')) : 'All files are correctly formatted' - def url = build.url + "consoleText" - - return "${Globals.resTicks[build.result]} $formattingMsg\n (${url})" -} - -def createVerifyMsgBody(builds) { - def msgList = builds.collect { type, build -> [ - 'type': type, 'res': build.result, 'url': build.url + "consoleText" ] - } - - return msgList.collect { - "${Globals.resTicks[it.res]} ${it.type} : ${it.res}\n (${it.url})" - } .join('\n') -} - node ('master') { if (hasChangeNumber()) { @@ -286,18 +266,14 @@ node ('master') { stage('Report to Gerrit'){ resCodeStyle = getLabelValue(1, Builds.codeStyle.result) - gerritReview( - labels: ['Code-Style': resCodeStyle], - message: createCodeStyleMsgBody(Builds.codeStyle, resCodeStyle)) + gerritReview labels: ['Code-Style': resCodeStyle] postCheck(new GerritCheck("codestyle", Builds.codeStyle)) def verificationResults = Builds.verification.collect { k, v -> v } def resVerify = verificationResults.inject(1) { acc, build -> getLabelValue(acc, build.result) } - gerritReview( - labels: ['Verified': resVerify], - message: createVerifyMsgBody(Builds.verification)) + gerritReview labels: ['Verified': resVerify] Builds.verification.each { type, build -> postCheck( new GerritCheck(type, build)