Scheduled pipelines
A schedule starts a pipeline at fixed times, such as every night or every Monday morning. A pipeline can have several schedules, each with its own name, timing, branch, and variable and secret groups.
A scheduled run does not belong to a person. It runs as a Scheduler account: a workspace account that has only the permissions an administrator granted to it. A schedule does not run until it has an account.
Declare a schedule
Schedules live in the pipeline’s ICE source, inside @triggers:
@triggers {
manual: {}
schedule: {
task_qa: { cron: "0 3 * * *", branch: "develop", variables: "qa" },
task_prod: { cron: "0 5 * * 1", timezone: "America/Sao_Paulo", variables: "prod", secrets: "prod" },
verifier: { cron: "0 5 * * 1" }
}
}
Separate the schedules with commas, and do not put a comma after the last one. The options are described in ICE syntax reference.
You do not have to write ICE by hand:
-
Open the pipeline and select the Schedules tab.
-
Select Add schedule, or Edit on a schedule.
-
Fill in Name, Cron and, when needed, Timezone, Branch, Variables and Secrets. Below the cron expression, the form shows when it runs next.
-
Select Save.
Saving commits the pipeline’s .ice file to the default branch with you as the author. If the project requires pull requests for pipeline changes, a pull request is opened instead, and the schedule changes after it is merged.
Renaming a schedule creates a new schedule: the account of the old name is not carried over.
Create a Scheduler account
Scheduler accounts belong to a workspace. Creating, renaming and deleting them requires administering the workspace.
-
Select Schedulers in the sidebar, then New account.
-
Give it a name such as
scheduler-qa, and select Create account.
A new account has no permissions. Grant it what its schedules need in the organization’s Access page, where the account appears among the principals when you search for its name:
-
a role that can run the pipeline, such as Pipeline Operator on the project;
-
Deployment Target Operator on each target it deploys to;
-
Registry Publisher on each Registry it pushes to;
-
Variable Group Consumer and Secret Group Consumer on the groups a schedule names in
variablesandsecrets.
An account cannot sign in and has no password or tokens.
Use one account per level of access. For example, scheduler-qa deploys only to QA and scheduler-prod only to production. A run has a single account, so a pipeline that deploys to QA and to production in the same run needs an account allowed to do both.
Choose who can use an account
Assigning an account to a schedule hands the pipeline that account’s permissions. For that reason, editing a pipeline is not enough: the person also needs permission to use the account.
Grant the Scheduler Account User role on the account to the people and teams that may use it. Workspace administrators can already use every account of the workspace.
Assign the account of a schedule
In the Schedules tab, choose the account in Runs as. The list shows only the accounts you can use. You also need permission to change the pipeline.
A schedule shows one of these states:
| Status | Meaning |
|---|---|
Active |
Runs as its account. The tab shows the next run. |
No account |
Does not run until an account is chosen. |
Suspended |
The pipeline changed and someone who can use the account must confirm the new version. |
Why a schedule is suspended
Once a schedule has an account, changing the pipeline changes what that account runs. To stop someone without access from borrowing the account, Codinamo checks who made each change to the pipeline:
-
A change made by someone who can use the account keeps the schedule running.
-
A change made by someone who cannot use it, or whose author is unknown, suspends the schedule. This covers the flow editor, commits from the web app,
git pushand merged pull requests.
A suspended schedule shows who changed the pipeline and in which commit. Someone who can use the account reviews the change and selects Confirm version. The schedule then runs again.
What a scheduled run receives
The run is labelled Scheduler · <schedule> as <account> in the run lists. It receives these variables:
| Variable | Value |
|---|---|
|
|
|
Name of the schedule. |
|
The schedule’s |
|
Empty: the run builds the latest commit of the branch. |
Without variables or secrets, the run uses the groups selected in the pipeline’s run panel.
When a run does not start
Occurrences start within about half a minute of their time. If Codinamo was unavailable at that time, the schedule runs once when it is back, not once for each missed occurrence.
The Schedule events list at the bottom of the tab, and codi pipeline events <pipeline> --type schedule, explain every occurrence that did not start:
-
the schedule has no account or is suspended (reported at most once a day);
-
the account cannot run the pipeline, or cannot use a variable or secret group the schedule names;
-
a group named by the schedule does not exist;
-
the organization cannot start runs, for example because the plan’s run minutes are exhausted.
A run that started but then failed, for example because the account cannot deploy to a target, appears as a failed run with the reason in its log.
Use the CLI
codi scheduler-account create scheduler-qa --description "Nightly deploys to QA"
codi scheduler-account list
codi pipeline schedule set deploy-app task_qa --cron "0 3 * * *" --branch develop --variables qa
codi pipeline schedule assign deploy-app task_qa --account scheduler-qa
codi pipeline schedule list deploy-app
codi pipeline schedule confirm deploy-app task_qa
codi pipeline schedule remove deploy-app task_qa