Use gerritCheck API for posting checker result
Since the upgrade to the Gerrit Code Review plugin v0.4.0, the integration with Checks is tighter and it isn't needed anymore to make a direct invocation of the Checks API to submit the checker result. Change-Id: Icc06094e0a66d7a0b2e1428dcb605395d4027501
This commit is contained in:
26
Jenkinsfile
vendored
26
Jenkinsfile
vendored
@@ -53,15 +53,11 @@ class Builds {
|
|||||||
|
|
||||||
class GerritCheck {
|
class GerritCheck {
|
||||||
String uuid
|
String uuid
|
||||||
String changeNum
|
|
||||||
String sha1
|
|
||||||
Build build
|
Build build
|
||||||
|
|
||||||
GerritCheck(name, changeNum, sha1, build) {
|
GerritCheck(name, build) {
|
||||||
this.uuid = "gerritforge:" + name.replaceAll("(bazel/)", "") +
|
this.uuid = "gerritforge:" + name.replaceAll("(bazel/)", "") +
|
||||||
Globals.gerritRepositoryNameSha1Suffix
|
Globals.gerritRepositoryNameSha1Suffix
|
||||||
this.changeNum = changeNum
|
|
||||||
this.sha1 = sha1
|
|
||||||
this.build = build
|
this.build = build
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,21 +89,7 @@ def hasChangeNumber() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def postCheck(check) {
|
def postCheck(check) {
|
||||||
def gerritPostUrl = Globals.gerritUrl +
|
gerritCheck(checks: [ "${check.uuid}" : "${check.getCheckResultFromBuild()}" ])
|
||||||
"a/changes/${check.changeNum}/revisions/${check.sha1}/checks"
|
|
||||||
|
|
||||||
try {
|
|
||||||
def json = check.createCheckPayload()
|
|
||||||
httpRequest(httpMode: 'POST', authentication: Globals.gerritCredentialsId,
|
|
||||||
contentType: 'APPLICATION_JSON', requestBody: json,
|
|
||||||
validResponseCodes: '200', url: gerritPostUrl)
|
|
||||||
echo "----------------------------------------------------------------------------"
|
|
||||||
echo "Gerrit Check: ${check.uuid}=" + check.build.result + " to change " +
|
|
||||||
check.changeNum + "/" + check.sha1
|
|
||||||
echo "----------------------------------------------------------------------------"
|
|
||||||
} catch(Exception e) {
|
|
||||||
echo "ERROR> Failed to post check results to Gerrit: ${e}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def queryChangedFiles(url, changeNum, sha1) {
|
def queryChangedFiles(url, changeNum, sha1) {
|
||||||
@@ -313,7 +295,7 @@ node ('master') {
|
|||||||
gerritReview(
|
gerritReview(
|
||||||
labels: ['Code-Style': resCodeStyle],
|
labels: ['Code-Style': resCodeStyle],
|
||||||
message: createCodeStyleMsgBody(Builds.codeStyle, resCodeStyle))
|
message: createCodeStyleMsgBody(Builds.codeStyle, resCodeStyle))
|
||||||
postCheck(new GerritCheck("codestyle", Change.number, Change.sha1, Builds.codeStyle))
|
postCheck(new GerritCheck("codestyle", Builds.codeStyle))
|
||||||
|
|
||||||
def verificationResults = Builds.verification.collect { k, v -> v }
|
def verificationResults = Builds.verification.collect { k, v -> v }
|
||||||
def resVerify = verificationResults.inject(1) {
|
def resVerify = verificationResults.inject(1) {
|
||||||
@@ -324,7 +306,7 @@ node ('master') {
|
|||||||
message: createVerifyMsgBody(Builds.verification))
|
message: createVerifyMsgBody(Builds.verification))
|
||||||
|
|
||||||
Builds.verification.each { type, build -> postCheck(
|
Builds.verification.each { type, build -> postCheck(
|
||||||
new GerritCheck(type, Change.number, Change.sha1, build)
|
new GerritCheck(type, build)
|
||||||
)}
|
)}
|
||||||
|
|
||||||
setResult(resVerify, resCodeStyle)
|
setResult(resVerify, resCodeStyle)
|
||||||
|
Reference in New Issue
Block a user