jenkinsci / jenkinsci/workflow-durable-task-step-plugin

[JENKINS-51010] Batch step marked as succeeded when set to return a non-zero value

Open
#561 1 comment 0 reactions 0 assignees View on GitHub
component:workflow-durable-task-step-plugin imported-jira-issue pipeline priority:minor resolution:unresolved
Dominant language
Java
Stars
46
Forks
110
PR merge metrics
No merged PRs in 30d

Description

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:

 

---
Originally reported by towel, imported from: Batch step marked as succeeded when set to return a non-zero value


  • status: Open
  • priority: Minor
  • component(s): workflow-durable-task-step-plugin
  • label(s): jenkins, pipeline, triaged-2018-11, windows
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20251212-090250

Raw content of original issue

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:

 

environment

```
Windows Server 2016 (Jenkins master)

Jenkins 2.107.2 LTS

Pipeline: Nodes and Processes 2.19
```

1 attachment

- [Untitled.png](https://issues.jenkins.io/secure/attachment/42315/Untitled.png)
> ![Untitled.png](https://issues.jenkins.io/secure/attachment/42315/Untitled.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.