Jim Hunziker
Jim Hunziker

Reputation: 15380

How do I check how Gitlab CI rules are being evaluated?

I'm trying to ensure that my Gitlab CI only runs on a particular host, regardless of the Enable/Disable CI status in the GUI. I have this at the top of my .gitlab-ci.yml file, but CI now runs nowhere. I've confirmed that the host value is as expected by disabling my header and printing it from one of the script jobs.

workflow:
  rules:
    - if: '$CI_SERVER_HOST != "run-here.example.com"'
      when: never

In other words, I'm sure that the value of CI_SERVER_HOST is run-here.example.com, and my pipelines still don't run anywhere. Removing the above header causes them to run everywhere.

Upvotes: 0

Views: 1171

Answers (1)

Origin
Origin

Reputation: 1417

You will also have to add an always to run it in other cases.

workflow:
  rules:
   - if: '$CI_SERVER_HOST != "run-here.example.com"'
     when: never
   - when: always

Could you check with this workflow.

Upvotes: 1

Related Questions