How to Run a Scheduled Pipeline in GitLab CI/CD
A pipeline schedule runs a ref on a cron timetable, and jobs can detect it via the schedule pipeline source.
Create the schedule under CI/CD to Pipeline schedules (cron plus a target branch). Gate nightly-only jobs with rules:if: $CI_PIPELINE_SOURCE == "schedule".
Steps
- Create a schedule in CI/CD to Pipeline schedules with a cron expression.
- Gate scheduled-only jobs with
$CI_PIPELINE_SOURCE == "schedule". - Pass schedule-specific values via the schedule's variables.
Pipeline
.gitlab-ci.yml
nightly-audit:
script: npm audit --audit-level=high
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- when: neverGotchas
- Schedules run as the user who owns them; ensure that user can access protected variables.
- The cron timezone is set on the schedule, so confirm it matches your intended window.
Related guides
How to Use rules for Conditional Jobs in GitLab CI/CDControl when a GitLab CI/CD job runs with rules, combining if conditions, changes filters, and when to add, s…
How to Run Merge Request Pipelines in GitLab CI/CDRun pipelines for merge requests in GitLab CI/CD with rules that match the merge_request_event source, exposi…