I am trying to make my second stage run even though one of the two jobs in the first stage fails, but I cannot get it to work as expected with the job status check function succeeded('JobName')
.
In the following YAML pipeline, I would expect it to run Stage2 even though Job2 fails, as long as Job1 succeeds, but it does not:
stages:
- stage: Stage1
jobs:
- job: Job1
steps:
- pwsh: echo "Job1"
- job: Job2
steps:
- pwsh: write-error "Job2 error"
- stage: Stage2
condition: succeeded('Job1')
jobs:
- job: Job3
steps:
- pwsh: echo "Job3"
How do I get Stage2 to run even though Job2 has failed, as long as Job1 has succeeded?
Using always()
will make Stage2 run always, but I would like it to depend the success state of Job1, regardless of Job2 state.
Related documentation: