Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab run pipeline only manually and not automatically

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
like image 520
Anant_Kumar Avatar asked Oct 27 '20 15:10

Anant_Kumar


People also ask

Which GitLab keyword is used to make sure the job doesn't run automatically?

To configure a job to be executed only when the pipeline has been scheduled, use the rules keyword.

What is manual job in GitLab?

In GitLab CI/CD you can easily configure a job to require manual intervention before it runs. The job gets added to the pipeline, but doesn't run until you click the play button on it. Notice that the manual job gets skipped, and the pipeline completes successfully even though the manual job did not get triggered.

How do I skip CI GitLab?

Push options for GitLab CI/CD You can use push options to skip a CI/CD pipeline, or pass CI/CD variables. Do not create a CI pipeline for the latest push. Only skips branch pipelines and not merge request pipelines. Provide CI/CD variables to be used in a CI pipeline, if one is created due to the push.


3 Answers

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 :)

like image 150
Ouma Avatar answered Oct 18 '22 01:10

Ouma


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
like image 44
M07 Avatar answered Oct 18 '22 00:10

M07


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.

like image 6
Drdoomsalot Avatar answered Oct 18 '22 01:10

Drdoomsalot