Allow defining scheduled pipelines triggers as yaml
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Proposal
Currently, pipelines can only be triggered on a schedule using the UI (CI/CD -> Schedules), or REST API. Ideally, it should be possible to define schedules in the .gitlab-ci.yml file. This has several benefits, but most importantly, we can use a single schedule definition and share it with other projects using include. This also complies with our policies to define (as much as possible) "as code".
See: https://support.gitlab.com/hc/en-us/requests/182472
Intended users
Proposal
Option A : In .gitlab-ci.yml (keeps all CI/CD config in one place)
Add a new top-level schedules keyword that allows defining multiple schedules directly from code. Proposed syntax:
schedules:
- name: Schedule name
cron: * * * * *
timezone: UTC # could come in future iteration
target_branch: main
variables: {} # could come in future iteration
Required fields:
namecron
Field with defaults values:
-
timezone: Defaults toUTC -
target_branch: Defaults toCI_DEFAULT_BRANCH -
variables: Defaults to an empty block{}
Option B : Separate .gitlab-pipeline-schedule.yml file
yaml
`# .gitlab/schedules.yml (on default branch) schedules:
- name: "Nightly build" cron: "0 2 * * *" ref: main variables: ENVIRONMENT: production`
Design ideas/questions
- Which option is the preferred configuration approach?
- Which takes precedence in case of conflict between
schedulesblock in thegitlab-ci.yml, schedules in UI or defined through the API? The last schedule change takes precedence