Task is running on Node.
Part of the yaml file for the pipeline is:
steps:
- script: |
#!/bin/bash
./plan.sh
displayName: "example deploy"
continueOnError: false
Now, when sometimes the ./plan.sh script fails: but it still shows as a success (green tick) in the pipeline. See below:
How do I make it show a "failed" red cross whenever it fails?
3
Answers
I was able to solve this by adding
In the start of the yaml file.
For your script step to signal failure, you need to make the script as a whole return a non-0 exit code. You may need some conditional logic in your script, checking the exit code from plan.sh after it returns.
What you are doing now is actually calling the bash script file from PowerShell. Your way of writing it cannot capture the error message. The correct way is as follows:
plan2.sh
pipeline YAML definition:
Successfully get the issue:
But usually, we use the bash task directly to run the bash script.
plan.sh
pipeline YAML definition part:
Successfully get the issue: