Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51010

Batch step marked as succeeded when set to return a non-zero value


      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
      [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:


            Unassigned Unassigned
            towel Yoav Miles
            0 Vote for this issue
            1 Start watching this issue