tillsanders
tillsanders

Reputation: 1936

Is there a better way to disable/skip a job in a GitLab CI pipeline than commenting everything out?

I have a job in a GitLab CI pipeline that I want to temporarily disable because it is not working. My test suites are running locally but not inside docker, so until I figure that out I want to skip the test job or the test stage.

I tried commenting out the stage, but then I get an error message from the CI validation: test job: chosen stage does not exist; available stages are .pre, build, deploy, .post

So I can simply comment out the entire job, but I was wondering if there was a better way?

Upvotes: 16

Views: 41804

Answers (3)

JackDePirate
JackDePirate

Reputation: 81

You can also use only to disable inherited jobs (see Gitlab reference):

inherited-job:
  only: []

Upvotes: 0

martin
martin

Reputation: 1328

If you want to disable a job that is defined by a template which has been included (possible from a separate repository), you can use a when: never rule (gitlab reference), like:

inherited-job:
  rules:
    - when: never

Upvotes: 2

tillsanders
tillsanders

Reputation: 1936

Turns out, there is! It's quite at the end of the very thorough documentation of GitLab CI: https://docs.gitlab.com/ee/ci/jobs/index.html#hide-jobs

Instead of using comments on the job or stage, simply prefix the job name with a dot ..

Example from the official documentation:

.hidden_job:
  script:
    - run test

Upvotes: 26

Related Questions