Search code examples
gitlabgitlab-ci

gitlab-ci: always run late stage and take failed/success from earlier stage


I have the following stages in .gitlab-ci.yml:

stages:
  - build
  - test-azure
  - test-after-analysis

If test-azure fails test-after-analysis is skipped unless I add the allow_failure: true then it continues but success is set based on test-after-analysis stage which always is true. (just gather metrics and logs from internal systems about the test-azure tests done).

How can I always run the test-after-analysis stage and let the pipeline output the test-azure status?


Solution

  • Instead of using allow_failure: on jobs in the test-azure stage, set when: always on the jobs in the test-after-analysis stage.

    when: always will ensure the job runs irrespective of the status of jobs in the previous stage -- even if the jobs don't have allow_failure: set.