Skip to content

Instantly share code, notes, and snippets.

@stephenmenton
Last active September 23, 2020 19:33
Show Gist options
  • Save stephenmenton/a43aa856f99ddfbd933bdb0fdda75f38 to your computer and use it in GitHub Desktop.
Save stephenmenton/a43aa856f99ddfbd933bdb0fdda75f38 to your computer and use it in GitHub Desktop.
scripted pipeline not updating build result
Jenkins in scripted pipeline is not updating currentBuild.result or currentBuild.currentResult on failure
currentBuild.result is null
currentBuild.getResult() is null
currentBuild.currentResult is 'SUCCESS'
currentBuild.rawBuild.result is null
currentBuild.rawBuild.getResult() is null
must explicitly set result
node('linux') {
try {
stage('fail') {
sh "exit 1"
}
} finally {
println currentBuild.currentResult
// expected: "FAILED"
// actual : "SUCCESS"
}
}
node('linux') {
try {
stage('fail') {
sh "exit 1"
}
} catch(e) {
currentBuild.result = 'FAILED'
throw e
} finally {
println currentBuild.currentResult
// expected: "FAILED"
// actual : "FAILED"
}
}
@ldelpozo6
Copy link

ldelpozo6 commented Sep 22, 2020

hello Stephen
Looking at your example and the one from: https://plugins.jenkins.io/logstash/ I can see that the result key with its value are part of the json payload, is it possible to do the same with other currentBuild variables like: startTimeInMillis, duration, etc. I've been trying to accomplish that with no luck, not sure If you can point me in the right direction. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment