Crontab Tasks
# Introduction
Unlike regular pipelines, crontab tasks trigger scheduled pipelines.
The format of crontab tasks follows the POSIX cron syntax
.
The time zone used is Asia/Shanghai
.
In the example below, the scheduled pipeline will run at 5:30 and 17:30 Beijing time every day.
During execution, the pipeline will be triggered by the person responsible for the crontab task,
and it will use the code from the main
branch.
The person responsible is the user who pushes the crontab task configuration (addition or modification) to the repository.
For example, if user A
pushes the configuration from the example to the main
branch,
then user A
will be the person responsible. If user B
later modifies the configuration
in the crontab: 30 5,17 * * *
event, then user B
becomes the person responsible.
If the person responsible for the crontab task is removed from the repository, the scheduled pipeline will fail. To update the person responsible, you can modify the crontab task configuration and push it again.
main:
# Regular push event pipeline
push:
- stages:
- name: test
script: echo 1
# Scheduled pipeline
"crontab: 30 5,17 * * *":
# Modifying the content can reassign the person responsible for the crontab task. It is recommended to modify the name to minimize the risk of issues.
- name: crontab-a
stages:
- name: test
script: echo 1
To provide a more reliable service, we have set a minimum time interval of 5 minutes for crontab tasks.
Crontab tasks with intervals less than 5 minutes (e.g., * * * * *
) cannot be successfully added.
# Configuration Breakdown
This section provides a detailed explanation of the configuration format and meaning for each part of the scheduled pipeline.
main:
"crontab: 30 5,17 * * *":
- stages:
- name: test
script: echo 1
# main
This part is the same as in regular pipelines and can be filled with any existing branch name in the project repository.
It represents the code that will be used when the scheduled pipeline is executed. For example, if set to main
,
the pipeline will use the code from the main
branch at the time of execution.
# crontab: 30 5,17 * * *
This part is slightly different from regular pipelines. For regular pipelines,
you would fill in Git webhook event names such as push
or pull_request
.
However, for scheduled pipelines, you need to use the format crontab: ${CRON}
.
crontab:
is a fixed prefix for the scheduled pipeline event name.${CRON}
represents the actual execution time and follows the standard POSIX cron syntax. You can use https://crontab.guru/ (opens new window) to convert it into a human-readable format.