I have a job that can fail in certain environments. I have a fallback job that does the same thing using another CI configuration. I want to execute the fallback job only if the previous one failed and I use when: on_failure
to do that. But in that case, I’d like the pipeline’ status to be success
if the fallback job succeeds. I’ve tried playing around with allow_failure
but it doesn’t do what I would like.
Example:
stages:
- Action
- Fallback
action:
stage: Action
script:
- echo "Job failing"
- false
fallback:
stage: Fallback
needs: ["action"]
rules:
- when: on_failure
script:
- true
I would like the pipeline to have a success
status but it is failed
.
With:
stages:
- Action
- Fallback
action:
stage: Action
allow_failure: true
script:
- echo "Job failing"
- false
fallback:
stage: Fallback
needs: ["action"]
rules:
- when: on_failure
script:
- true
The fallback job is skipped because we allow failures for the previous job.
It’s even more complicated than that in my case. Because the action
job will fail to start if executed on a certain type of runner. Then the fallback job should execute and set the pipeline overall status. Or if the action
job starts but fails, the fallback
should not trigger and the pipeline status should be failed
.
Any idea?