CI/CD Pipeline - Don't trigger job if another job marked with allow_failure: true fail

Don’t trigger job if another job marked with allow_failure: true fail

Some time, it’s necessary to mark a job as allow_failure: true to not block some merge request in case of issue on dependency.

In this case, I don’t want subsequent job with needs dependency over the failing one to be run.

But if the first job fail, because of allow_failure, dependent one will be triggered and will fail too.

Example :

job-a:
  stage: build
  allow_failure: true
  needs: []
  script:
    - exit 1
  artifacts:
      paths:
        - test

job-b:
  stage: test
  needs:
    - job: job-a
      artifacts: true
  script:
    - ...

I tried when:on_success over job-b but looks like allow_failure by_pass on_success clause
There is a way to do it ?

I can mark the second one with allow_failure too, but it’ll consume compute and I want to avoid it

Thanks for taking time to answer :blush:

2 Likes

Did you happen to find a solution to this?

Looking as well … :confused:

I also need this.