Report to Checks when the build starts
Give the feedback to the Checks plugin about the exact
moment of the start of the Gerrit builds.
Provides three benefits:
- Gives immediate feedback to the Checks GUI that the build is running
- Provides the link to the build running log
- Measures the start and total time of the build
Change-Id: Ic20bf96e607ab65985c5474f3a34213e17534115
diff --git a/Jenkinsfile b/Jenkinsfile
index 631efcd..b4a3c61 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -54,7 +54,10 @@
}
def getCheckResultFromBuild() {
- def resultString = build.result.toString()
+ if (!build.getResult()) {
+ return "RUNNING"
+ }
+ def resultString = build.getResult().toString()
if (resultString == 'SUCCESS') {
return "SUCCESSFUL"
} else if (resultString == 'NOT_BUILT' || resultString == 'ABORTED') {
@@ -108,6 +111,9 @@
def slaveBuild = null
for (int i = 1; i <= retryTimes; i++) {
try {
+ postCheck(new GerritCheck(
+ (buildName == "Gerrit-codestyle") ? "codestyle" : mode,
+ new Build(currentBuild.getAbsoluteUrl(), null)))
slaveBuild = build job: "${buildName}", parameters: [
string(name: 'REFSPEC', value: "refs/changes/${env.BRANCH_NAME}"),
string(name: 'BRANCH', value: env.GERRIT_PATCHSET_REVISION),
@@ -119,9 +125,11 @@
if (buildName == "Gerrit-codestyle"){
Builds.codeStyle = new Build(
slaveBuild.getAbsoluteUrl(), slaveBuild.getResult())
+ postCheck(new GerritCheck("codestyle", Builds.codeStyle))
} else {
Builds.verification[mode] = new Build(
slaveBuild.getAbsoluteUrl(), slaveBuild.getResult())
+ postCheck(new GerritCheck(mode, Builds.verification[mode]))
}
if (slaveBuild.getResult() == "SUCCESS") {
break
@@ -235,7 +243,6 @@
stage('Report to Gerrit'){
resCodeStyle = getLabelValue(1, Builds.codeStyle.result)
gerritReview labels: ['Code-Style': resCodeStyle]
- postCheck(new GerritCheck("codestyle", Builds.codeStyle))
def verificationResults = Builds.verification.collect { k, v -> v }
def resVerify = verificationResults.inject(1) {
@@ -243,10 +250,6 @@
}
gerritReview labels: ['Verified': resVerify]
- Builds.verification.each { type, build -> postCheck(
- new GerritCheck(type, build)
- )}
-
setResult(resVerify, resCodeStyle)
}
}