Skip to content
Latchkey

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

Gotchas

  • 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

Run this faster and cheaper on Latchkey managed runners. Start free →