How to disable auto pipelines in gitlab
Asked Answered
S

3

24

Since gitlab limited free tier minutes on gitlab CI/CD. I would like to disable auto start for my pipeline after commit.

I would like to run pipeline only manually by click in gitlab interface.

How can I do it?

Settler answered 7/11, 2020 at 8:42 Comment(1)
Does this answer your question? Disable pipeline for every commit in Gitlab and only run it on open merge requestEpicotyl
C
41

You can disable the Gitlab CI/CD Pipelines in project by following steps:

  1. Go to Project's Settings >> General >> Visibility, project features, permissions
  2. Expand the Repository section
  3. Enable or Disable the CI/CD toggle
  4. Then, click on Save Changes

You can verify the same, the CI/CD option has been disappeared from left-hand side panel.

enter image description here



I have now updated the answer with reference to question:

Adding [ci skip] or [skip ci] inside the commit message will not trigger a pipeline on push.

More reference: https://docs.gitlab.com/ee/ci/yaml/#skip-pipeline

Cody answered 8/11, 2020 at 13:44 Comment(5)
He asked for a way to deactivate automatic pipeline starts but to keep the ability to start the pipeline manuallyCalypso
The setting has moved and can be found under Settings > General > CI/CD.Urgent
@AlexanderEble can you share which option it is? I can't see the same options under CI/CDLouvain
@Louvain Be aware that is not Settings > CI/CD but Settings > General > CI/CD.Urgent
Thank you @AlexanderEble to suggest the edits.Cody
E
18

You can add the following code to your .gitlab-ci.yml:

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "web"'

More reference: https://docs.gitlab.com/ee/ci/yaml/README.html#workflow https://docs.gitlab.com/ee/ci/yaml/README.html#common-if-clauses-for-rules

Erma answered 26/3, 2021 at 20:1 Comment(2)
This is pretty cool, thanks!Vietcong
It has to the answer to the question! Thanks Lucas!Warp
W
0

I just want to clarify a bit Lucas Lucas Hillesheim (@lucas-hillesheim) answer.

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "web"'

CI/CD can be triggered by different events. Gitlab suggests to use workflow keyword to control such behaviour. $CI_PIPELINE_SOURCE == "web" leads to run pipeline only when user pushes button on web page. All other events such as push, merge_request_event and other will not lead to running pipeline.

Indeed, it the best way to prevent auto CI/CD running, because in cases when I need to use only/except for specific jobs - are just workarounds. Firstly, because the question is to how to not run CI/CD every time, but with job rules, the pipeline itself is run anyway. Secondly, if I have many jobs with complex needs between them - using more conditions just for job starting is a nightmare. Thirdly, it still leads to flooding unfinished/canceled pipelines on pipeline webpage.

Warp answered 13/3 at 20:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.