Do not run pipline on another instance

Dear Community,

I have two GitLab instances, one of which is only a backup instance.
Unfort. also the backup instance wants to run my pipelines.

So I was hoping to avoid that by checking the CI_SERVER_NAME:

  - test
  - deploy
  - release

  stage: test
    - if: $CI_COMMIT_TAG =~ /^version-.*$/
    - if: $CI_SERVER_NAME =~ /^main.gitlab$/
    - |

Still the other instance, named backup.gitlab, complains that the pipeline is stuck.
Are the rules executed on the runner? So I would need to check this already at stages …

How to avoid running my pipelines on secondary instances with no CI or different CI configuration?


Hi @Perschak

- if: $CI_SERVER_NAME =~ /^main.gitlab$/ should be first.

I assume your “backup” instance is a copy/clone or something similar. GitLab does not understand “backup instance” (I fact I think you could achieve whatever you need without a running secondary instance), so unless there is .gitlab-ci.yml file it will try to run pipelines.

I changed my code to:

  stage: test
    - if: $CI_SERVER_NAME !~ /^main.gitlab$/
      when: never
    - if: $CI_COMMIT_TAG =~ /^version-.*$/

Thank You!