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
diff --git a/Jenkinsfile b/Jenkinsfile index 085cc65..f2d361e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile
@@ -63,17 +63,15 @@ } 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" } }