'Running parallel tasks on Azure using bash
I am trying to run parallel commands on Azure using the bash script. The script is working correctly when all are successful. When one of them fails, the other processes are properly killed but the step is marked as successful. What am I missing?
- job: main
pool:
vmImageL 'ubuntu-latest'
steps:
# some steps before
- bash: |
PIDS=()
my_command_1 &
PIDS+=($!)
my_command_2 &
PIDS+=($!)
my_command_3 &
PIDS+=($!)
for pid in "${PIDS[@]}"; do
wait $pid
done
# some steps after
The same script used in CircleCI and on GitHub Actions is working.
Solution 1:[1]
Found the issue.
By adding set -eu at the beginning of the bash script block, we ensure the step will return the error code when any of the commands fail.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Miroslav Jonas |
