How to trigger pipeline manually in GitLab CICD?
How to trigger pipeline manually in GitLab CICD?
1. Nov. 2023

Setting a job as manual in a CI/CD pipeline can be beneficial in various scenarios where you want to introduce human intervention, control, or decision-making into the automation process. Here are some common reasons why you might need to set a job as manual:

  • Deployment to Production: One of the most common use cases for manual jobs is deploying to a production environment. Before deploying changes to production, you may want a human operator to review the changes, confirm the deployment, and ensure everything is working as expected to prevent accidental or automated deployment of potentially harmful changes.

  • Quality Assurance (QA) or Testing: In situations where manual testing or quality assurance is necessary, you can create manual jobs that pause the pipeline to allow testers or QA professionals to review the changes, perform manual tests, and report their findings before proceeding.

  • Security Scans and Audits: Manual jobs can be used to pause the pipeline for security scans or audits that require human assessment. For example, you might want to manually review the results of a security scan before proceeding with the deployment.

By using manual jobs strategically in your CI/CD pipeline, you can strike a balance between automation and human oversight, ensuring that critical processes are carefully controlled and validated before moving forward. This can help maintain the reliability, security, and quality of your software deployments and operations.

To create a manual job in GitLab, you can use the when: manual attribute in your .gitlab-ci.yml file. This attribute will cause the job to wait for manual intervention before it is executed. You can also add a custom message to the job when you manually execute it, which can be used to provide context or instructions to other users who may be viewing the pipeline.

Here is an example of a manual job in GitLab:

stages:
  - build
  - test
  - deploy

build:
  stage: build
  script:
    - echo "Building..."

test:
  stage: test
  script:
    - echo "Testing..."

deploy:
  stage: deploy
  script:
    - echo "Deploying..."
  when: manual

In this example, the deploy job is set to manual, which means it will wait for manual intervention before it is executed.

To trigger the manual job, you can go to the pipeline view for your project and find the job that requires manual intervention. The job will be displayed in a "manual" state, indicating that it is waiting for manual intervention. Click the "play" button next to the job to manually execute it.

GitLab Manual Pipeline

Manual pipelines can be useful in situations where you need to perform a task that requires manual intervention, such as deploying to production or performing a security audit. By requiring manual intervention, you can ensure that the task is only executed when you are ready and have reviewed any relevant information or data.