Alex
Alex

Reputation: 44385

Why is a stage in my gitlab pipeline omitted?

I have the following gitlab configuration:

stages:
  - test
  - stage1
  - stage2

test:
  rules:
    - if: $CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "schedule"
      when: never
  stage: test
  script:
    - 'echo "Running Test"'

my_stage1:
  stage: stage1
  script:
    - 'echo "Running stage 1"'

my_stage2:
  stage: stage2
  script:
    - 'echo "Running stage 2"'

and I create a merge request. I expect that all three stages are run in that case, but the first stage is not run. Why? How to fix it? The documentation on that it very unclear!

The content of CI_PIPELINE_SOURCE is merge-request-event.

Upvotes: 2

Views: 1408

Answers (1)

David Buck
David Buck

Reputation: 3830

Looking at the documentation here, when you are using a when:never it needs to be followed by a specific success clause, in order for it to run in other cases e.g.:

test:
  rules:
    - if: $CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - when: on_success

Upvotes: 2

Related Questions