You can schedule cronjobs by defining a
cron resource in your
.drone.yml configuration file. In the below example we schedule a daily job that executes a pipeline against the latest commit in the
--- kind: pipeline name: default steps: - name: build image: golang commands: - go build - go test --- kind: cron name: daily spec: schedule: "0 0 0 * * *" branch: master ...
The system automatically synchronizes the defined cron resources every time you push to your default branch (typically master). In order to add or remove a cronjob you therefore need to update your yaml, and push the change to your default branch.
It is important to note that changes to your cron configuration will not take effect until pushed to your default branch. This prevents pull requests and feature branches from inadvertently updating the cron configuration.
The current implementation calculates the execution time based on UTC as opposed to local time. This behavior may change in the future.
The current implementation does not aim to provide precise, to-the-minute, execution of cron jobs. By default, cron jobs are batch executed every 30 minutes. Execution frequency under 30 minutes is therefore prohibited.
Run once a week, at midnight, between Saturday and Sunday:
--- kind: cron name: weekly spec: schedule: "0 0 0 * * 0" branch: master ...
Run once a day, at midnight:
--- kind: cron name: daily spec: schedule: "0 0 0 * * *" branch: master ...
Run once an hour, at the beginning of the hour:
--- kind: cron name: hourly spec: schedule: "0 0 * * * *" branch: master ...