DevOps / GitLab CI Basics Interview Questions
What are manual jobs in GitLab CI/CD and how do you configure them?
A manual job is a job that is added to the pipeline but does not run automatically - it requires someone to click a button in the GitLab UI (or API call) to trigger it. Manual jobs are commonly used for production deployments that need human approval.
# Method 1: using rules deploy-production: stage: deploy script: - ./deploy.sh production environment: production rules: - if: $CI_COMMIT_BRANCH == "main" when: manual # must be clicked to run allow_failure: false # blocks pipeline completion until clicked # Method 2: legacy "when" keyword deploy-prod-legacy: stage: deploy script: ./deploy.sh production when: manual only: - main # Blocking vs non-blocking manual jobs: # Non-blocking (default): pipeline is marked as passed without clicking # Blocking: pipeline stays in "blocked" status until job is triggered # To make it blocking (requires allow_failure: false): critical-approval: stage: approve script: echo "Approval recorded" when: manual allow_failure: false # blocks the pipeline # Protected manual jobs (only certain roles can trigger): # Set in project Settings > CI/CD > Protected environments
allow_failure with manual jobs: when when: manual is set without allow_failure: false, the job is non-blocking - the pipeline proceeds (and can pass) without the manual job being triggered. With allow_failure: false, the pipeline stays in a blocked state until someone triggers the manual job.
More Related questions...