How to quickly disable / enable stages in Gitlab CI

Viewed 31647

When you work on your .gitlab-ci.yml for a big project, for example having a time consuming testing stage causes a lot of delay. Is there an easy way to disable that stage, as just removing it from the stages definition, will make the YAML invalid from Gitlab's point of view (since there's a defined but unused stage), and in my case results in:

test job: chosen stage does not exist; available stages are .pre, build, deploy, .post

Since YAML does not support block comments, you'd need to comment out every line of the offending stage.

Are there quicker ways?

4 Answers

There is a way to disable individual jobs (but not stages) like this:

test:
  stage: test
  when: manual

The jobs are skipped by default, but still can be triggered in the UI:

Gitlab CI screenshot

Also possible with rules and when as below:

test:
  stage: test
  rules:
   - when: never

So far, the easiest way I've found is to use a rules definition like so:

test:
  stage: test
  rules:
    - if: '"1" != "1"'
(...)

This still feels a bit odd, so if you have a better solution, I'll gladly accept another answer.

Related