Can't figure out why the pipeline does not run

20 views Asked by At

I'm learning how to use Gitlab CICD. Below is my .gitlab-ci.yml file

variables:
  VAR1:
    value: "red"
    options: ["red", "blue"]
  VAR2:
    value: "bar"
    options: ["foo", "bar"]

pre_job:
  stage: .pre
  image: alpine:latest
  script: echo "I'm a pre job"
  when: always

red_job:
  stage: build
  image: alpine:latest
  script: echo "I'm red job"
  rules: 
    - if: $VAR1 == "red" && $VAR2 == "foo"

blue_job:
  stage: build
  image: alpine:latest
  script: echo "I'm blue job"
  rules: 
    - if: $VAR1 == "blue" && $VAR2 == "foo"

The condition for both red_job and blue_job are not met. So, I'm still expecting the pre_job to run. But the pipeline does not run at all.

Can someone help to point out what I'm doing wrong here?

1

There are 1 answers

0
KompjoeFriek On

From https://docs.gitlab.com/ee/ci/yaml/#stages:

If a pipeline contains only jobs in the .pre or .post stages, it does not run.