I am not sure if it is by design or not, but my experience is that setting currentBuild.result is unreliable. For example I saw it ‘cause’ a subsequent crash in the xunit results parser. So what I have settled on is using the groovy post-build API to set this, and treating ‘currentBuild.result’ as read-only.
From: [email protected] [mailto:[email protected]] On Behalf Of Tomas Pekarovic Sent: Tuesday, March 28, 2017 3:13 PM To: [email protected] Subject: Re: Build always ends with FAILURE after setting currentBuild.result = 'STABLE' / 'SUCCESS' Thanks, but this approach is not working. 1) junit 'res.xml' will always report unstable ( I just can't get it to report something else) 2) catch will not catch unstable build 3) I tried: ..... parallel( "test1": { node('master'){ bat 'exit 0' bat 'type ei_result.xml > res.xml' try { junit 'res.xml' if (currentBuild.result == 'UNSTABLE'){ currentBuild.result = 'SUCCESS' } } catch(err) { throw(err) } } }, "test2": { node('robot'){ echo "dfds" } ....... It's always ending up Yellow, as unstable On Tue, Mar 28, 2017 at 7:59 PM, <[email protected]<mailto:[email protected]>> wrote: This seem like a declarative way bug too me. I do this into full scripts (changing the current build result) and it work fine. I haven't tested the declarative (post {}, always {}, ...), but you could try a Jenkinsfile without the declarative syntax: node() { try { // make you junit test that make unstable here }catch() { if (currentBuild.result == 'UNSTABLE') currentBuild.result = 'SUCCESS' } } This should work, if so, it mean that the declarative syntax have a bug in it and the currentBuild.result is somehow a copy used into the post scope and restore after the processing of the declarative post {}. You should open a bug report if so. -- You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/r35UO_Ji4c8/unsubscribe. To unsubscribe from this group and all its topics, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c18bc05d-ba2e-44e5-8a0f-ffd2dd42e306%40googlegroups.com<https://groups.google.com/d/msgid/jenkinsci-users/c18bc05d-ba2e-44e5-8a0f-ffd2dd42e306%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAKokUHBRdQ1LFPgc7WzPPojzz4hpFnMzjPX_%2BqW3Q%3DEu8jAbTw%40mail.gmail.com<https://groups.google.com/d/msgid/jenkinsci-users/CAKokUHBRdQ1LFPgc7WzPPojzz4hpFnMzjPX_%2BqW3Q%3DEu8jAbTw%40mail.gmail.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CY1PR0301MB199682BC486482F487772C04B8320%40CY1PR0301MB1996.namprd03.prod.outlook.com. For more options, visit https://groups.google.com/d/optout.
