Sobes.tech
Junior — Middle

How do you manually and on-demand run a task in GitLab CI?

sobes.tech AI

Answer from AI

In GitLab CI, you can manually trigger jobs on demand using the when: manual keyword in the job description in .gitlab-ci.yml.

Example:

job_name:
  script:
    - echo "Manual job trigger"
  when: manual
  allow_failure: false

After that, a "Play" button will appear in the GitLab interface next to this job, and you can trigger it manually.

You can also run the entire pipeline manually through the GitLab interface by selecting the desired branch and clicking "Run pipeline".

To trigger on demand (for example, with parameters), you can use trigger tokens or the GitLab API, sending POST requests to start a pipeline with the required parameters.

Thus, manual triggering is implemented via when: manual for individual jobs and through the interface or API for the entire pipeline.