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

2

13

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?

Democritus answered 9/2, 2021 at 9:54 Comment(0)
D
22

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
Democritus answered 9/2, 2021 at 9:54 Comment(2)
This does not work that well when you use templates that are located in a dedicated repo and included.Elfie
Duplicate of #64992549Unstoppable
K
0

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
Kilohertz answered 2/4 at 9:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.