-
Bug
-
Resolution: Unresolved
-
Minor
-
Windows Server 2016 (Jenkins master)
Jenkins 2.107.2 LTS
Pipeline: Nodes and Processes 2.19
When I use returnStatus I get the return code, but the bat step itself doesn't show as failed in the Pipeline Steps page. Consider the following example:
node {
stage ('example') {
int rc = bat([script: 'exit 1', returnStatus: true])
if (rc) {
println 'Failed!'
{{ }}}
else {
println 'Success!'
{{ }}}
{{ }}}
}
This is the output of the build:
Started by user anonymous
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in D:\Jenkins\workspace\bat
[Pipeline] {
[Pipeline] stage
[Pipeline] { (example)
[Pipeline] bat
[bat] Running batch script
D:\Jenkins\workspace\bat>exit 1
[Pipeline] echo
Failed!
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
This is expected, but as you can see the batch script step itself isn't marked as failed:
[JENKINS-51010] Batch step marked as succeeded when set to return a non-zero value
Description |
Original:
When I use {{returnStatus}} I get the return code, but the {{bat}} step itself doesn't show as failed in the Pipeline Steps page. Consider the following example: {{node \{}} {{ stage ('example') \{}} {{ int rc = bat([script: 'exit 1', returnStatus: true])}} {{ if (rc) \{}} {{ println 'Failed!'}} {{ }}} {{ else \{}} {{ println 'Success!'}} {{ }}} {{ }}} {{}}} This is the output of the build: {{Started by user {color:#205081}+anonymous+{color}}} {{ Running in Durability level: MAX_SURVIVABILITY}} {{{color:#cccccc}[Pipeline] node{color}}} {{Running on {color:#205081}+Jenkins+{color} in D:\Jenkins\workspace\bat}} {{{color:#cccccc}[Pipeline] \{{color}}} {{{color:#cccccc}[Pipeline] stage{color}}} {{{color:#cccccc}[Pipeline] \{ (example){color}}} {{{color:#cccccc}[Pipeline] bat{color}}} {{[bat] Running batch script}} {{D:\Jenkins\workspace\bat>exit 1 }} {{{color:#cccccc}[Pipeline] echo{color}}} {{ Failed!}} {{{color:#cccccc}[Pipeline] }{color}}} {{{color:#cccccc}[Pipeline] // stage{color}}} {{{color:#cccccc}[Pipeline] }{color}}} {{{color:#cccccc}[Pipeline] // node{color}}} {{{color:#cccccc}[Pipeline] End of Pipeline{color}}} {{Finished: SUCCESS}} {{ }} This is expected, but as you can see the batch script step itself isn't marked as failed: !Untitled.png! |
New:
When I use {{returnStatus}} I get the return code, but the {{bat}} step itself doesn't show as failed in the Pipeline Steps page. Consider the following example: {{node \{}} {{ stage ('example') \{}} {{ int rc = bat([script: 'exit 1', returnStatus: true])}} {{ if (rc) \{}} {{ println 'Failed!'}} {{ }}} {{ else \{}} {{ println 'Success!'}} {{ }}} {{ }}} {{}}} This is the output of the build: {{Started by user {color:#205081}+anonymous+{color}}} {{Running in Durability level: MAX_SURVIVABILITY}} {{{color:#cccccc}[Pipeline] node{color}}} {{Running on {color:#205081}+Jenkins+{color} in D:\Jenkins\workspace\bat}} {{{color:#cccccc}[Pipeline] \{{color}}} {{{color:#cccccc}[Pipeline] stage{color}}} {{{color:#cccccc}[Pipeline] \{ (example){color}}} {{{color:#cccccc}[Pipeline] bat{color}}} {{[bat] Running batch script}} {{D:\Jenkins\workspace\bat>exit 1}} {{{color:#cccccc}[Pipeline] echo{color}}} {{Failed!}} {{{color:#cccccc}[Pipeline] }{color}}} {{{color:#cccccc}[Pipeline] // stage{color}}} {{{color:#cccccc}[Pipeline] }{color}}} {{{color:#cccccc}[Pipeline] // node{color}}} {{{color:#cccccc}[Pipeline] End of Pipeline{color}}} {{Finished: SUCCESS}} This is expected, but as you can see the batch script step itself isn't marked as failed: !Untitled.png! |
Labels | Original: jenkins pipeline windows | New: jenkins pipeline triaged-2018-11 windows |
I know I can use a try/catch block instead of returnStatus, but the exception that is thrown is hudson.AbortException and I don't want to lose the ability to abort the build manually (plus I wouldn't know what was the return code).