GitLab run pipeline only manually and not automatically

Viewed 9559

My GitLab pipelines execute automatically on every push, I want to manually run pipeline and not on every push.

Pipeline docs: https://docs.gitlab.com/ee/ci/yaml/#workflowrules

I tried this in .gitlab-ci.yml

workflow:
  rules:
    - when: manual    # Error: workflow:rules:rule when unknown value: manual
3 Answers

We can define your jobs to be only executed on Gitlab. The web option is used for pipelines created by using Run pipeline button in the GitLab UI, from the project's CI/CD > Pipelines section.

only:
   - web

as mentioned in the documentation, I think you should specify a condition that tells Gitlab to not run the pipeline specifically on push events like so:

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
      when: never  # Prevent pipeline run for push event
    - when: always # Run pipeline for all other cases

Well, this was all from the official documentation but I hope that this may help you :)

Here is the solution I cam up with:

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "web"'
      when: always
    - when: never

This specifies that it will only run if you click the "Run Pipeline" button in the web UI. In all other cases it will not be triggered.

Related