| Hi Devin Nusbaum, I used currentBuild.currentResult in a good number of places and was affected by this issue. I think we should revert it or provide an alternative way. I used it with at least 4 different plugins: Slack, MS Teams, Email Ext and InfluxDB. For Slack is basically similar to what has being described already:
String slackMessage() {
"Build *${env.JOB_NAME}* finished with status *${currentBuild.currentResult}*"
}
String slackColor() {
"${currentBuild.currentResult == 'SUCCESS' ? 'good' : 'danger'}"
}
I don't want to have to repeat the above for each type of result, instead, is easier on the pipeline library to just read the status as above. For MS teams I have got:
pipeline.office365ConnectorSend message: 'Build completed',
status: currentBuild.currentResult,
webhookUrl: msTeamsWebhookUrl,
color: currentBuild.currentResult == 'SUCCESS' ? '82C441' : 'C81423'
Same use case as Slack. Another case with Slack and MS Teams is that we use a combination of lock and milestone plugins, so sometimes a build is skipped and the result is NOT_BUILT, so we have this:
if (currentBuild.currentResult == 'NOT_BUILT') {
//don't send Slack / MS Teams message in this case as this build has being skipped by lock/milestone
}
Now, the tricky cases are Email Ext (plugin id = email-ext) and InfluxDB (plugin id = influxdb). They need a value on currentBuild.result to function properly. So for both of them I have to do this before using the plugins:
//to fix issue where mailer needs 'currentBuild.result' which is always null at this point - without this email does not report build result correctly
currentBuild.result = currentBuild.currentResult
step([$class: 'Mailer', recipients: emailList])
And InfluxDB:
//to fix issue where InfluxDbPublisher needs 'currentBuild.result' which is always null at this point - without this build result is not reported to InfluxDB
currentBuild.result = currentBuild.currentResult
step([$class: 'InfluxDbPublisher', target: 'influxdb'])
Both Email Ext (plugin id = email-ext) and InfluxDB (plugin id = influxdb) are a bit old (they don't seem to support Declarative Pipelines directly, and instead we need to use step). After this bug was introduced I have easy way of "fixing" this two plugins and all of the above cases stopped working for me. |