Avoid use of switch on String for Checks API results

After the recent upgrades of Jenkins and the pipeline-related
plugins, the Groovy switch on string for the build results conversion
into the Checkers result returned null causing build failures.

Use the safer if/then/else construct that works also with
the latest Groovy/CPS sandbox.

Change-Id: Ibb4ea9d8b6669a548be1826519deaf008304dcf6
This commit is contained in:
Luca Milanesio 2020-01-10 18:16:23 +00:00
parent 35818c80dc
commit 97caed1d34

18
Jenkinsfile vendored
View File

@ -63,17 +63,15 @@ class GerritCheck {
}
def getCheckResultFromBuild() {
switch(build.result) {
case 'SUCCESS':
return "SUCCESSFUL"
case 'NOT_BUILT':
case 'ABORTED':
return "NOT_STARTED"
case 'FAILURE':
case 'UNSTABLE':
default:
return "FAILED"
def resultString = build.result.toString()
if (resultString == 'SUCCESS') {
return "SUCCESSFUL"
} else if (resultString == 'NOT_BUILT' || resultString == 'ABORTED') {
return "NOT_STARTED"
}
// Remaining options: 'FAILURE' or 'UNSTABLE':
return "FAILED"
}
}