Last active
September 23, 2020 19:33
-
-
Save stephenmenton/a43aa856f99ddfbd933bdb0fdda75f38 to your computer and use it in GitHub Desktop.
scripted pipeline not updating build result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node('linux') { | |
try { | |
stage('fail') { | |
sh "exit 1" | |
} | |
} finally { | |
println currentBuild.currentResult | |
// expected: "FAILED" | |
// actual : "SUCCESS" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node('linux') { | |
try { | |
stage('fail') { | |
sh "exit 1" | |
} | |
} catch(e) { | |
currentBuild.result = 'FAILED' | |
throw e | |
} finally { | |
println currentBuild.currentResult | |
// expected: "FAILED" | |
// actual : "FAILED" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!