Templates and schedules
A template is a saved run spec with a name, in a project. Use one for a run you start again and again, such as a build or a nightly job. Parameters are the values you choose each time. A schedule starts a template on a timetable. Templates can also be started by Git triggers and used as steps of flows.
Make a template
On the project's Templates page, choose New template. Give it a Name (letters, digits,
., _ and -, unique in the project), a Description and its Run spec, then choose
Save template. Saving needs template:write; developers and up have it.
Parameters
Under Parameters, Add parameter for each value that changes between runs. Each has a type
(Text, Number, Yes/no or Choice, with up to 100 options) and either a Default
or Required. The spec refers to a parameter as ${params.NAME} in the image, command,
arguments, working directory, env values and runner label values:
image: golang:${params.go}
commands:
- name: build
run: make build TARGET=${params.target}
$${params.NAME} keeps the text as it is. The spec is checked with sample values when you save,
so a saved template can always be started.
Versions
Every save that changes the template makes a new version. Saving without changes makes none. Versions never change, and each run records the template and version it came from ("From template" on the run page). The template's page lists its Versions and can show any of them. Deleting a template keeps its runs.
Locked environment and retries
- Locked environment: ticked names of the spec's env can't be changed when the template is started, by hand, by a schedule or by a trigger.
- Retries: a run that fails, times out, is lost with its runner, or can't pull its image or check out its commit can start again by itself as a new run. Choose 1 to 10 Attempts, the First wait and the Longest wait; the wait doubles after each attempt. Cancelled runs never start again.
Start a template
On the template's page, choose Launch. Fill in the parameters, optionally a Run name and
Extra environment (NAME=value per line, except the locked names), and choose Start run.
Starting needs run:create, and secret:use when the spec uses secrets.
From the command line:
forge templates # the project's templates and the organization's
forge templates build # one template's parameters
forge run --template build --param target=prod --param go=1.24
forge run -d --template build --param target=prod --env DEBUG=1 --version 2
With --template, only --param, --version, --env, --name and --detach (-d) apply;
the template has the rest of the spec. Without --version, the latest version starts. Like any
forge run, it follows the output and exits with the run's exit code unless detached. Pick the
project with --project ORG/PROJECT or FORGE_PROJECT.
Organization templates
An organization can keep templates every project of it can use, on the organization's
Templates page. Saving them needs template:write on the organization (owners and admins have
it). Every member can read them.
- They run in a project, with that project's variables, secrets, quota and runners. A project's Templates page lists them after its own, marked "organization", and starts, schedules and triggers them there. They are changed only on the organization's page.
- Flows and the command line name them
@org/NAME, or@org/NAME@3for version 3:forge run --template @org/build. - Allowed versions limits which versions projects may run. With none ticked, all may.
@org/NAMEthen runs the newest allowed one, and a run pinned to another is refused. - Where it's used shows, per project, its runs of each version in the last 30 days and its schedules and triggers.
Schedules
A schedule starts runs of a template's latest version at set times. On the template's page, choose New schedule. The project's Schedules page lists them all. A saved flow can have schedules too, which start flow runs.
Timing
- Cron expression: five fields, minute, hour, day of month, month and day of week. For
example
0 3 * * *is every day at 03:00,*/15 * * * *every 15 minutes and0 9 * * 1-5weekdays at 09:00.@hourly,@daily,@weekly,@monthlyand@yearlywork too. - Time zone: cron times are in this zone, such as
Europe/Amsterdam, including summer time changes. - Every so many minutes: counted from when the schedule is saved.
A schedule fires at most once a minute. The schedule's page shows the next five fire times.
Who it runs as
A schedule runs as a service account of the project, never as
the person who made it. You can only pick accounts whose role you could grant, and creating or
changing a schedule needs schedule:write. The account is checked at every fire: if it was
deleted, or its role can't start runs or use the secrets, the fire fails.
When runs overlap or are missed
When a run is still active:
- Start another run (the default);
- Skip this time;
- Cancel the active run and start a new one.
Missed fire times are those more than a minute in the past, for example while Forge was down:
- Skip them (the default);
- Start one run for the latest, if it isn't too old, within the Maximum age you set.
There is never a burst of catch-up runs.
Values and history
A schedule has its own Parameters values and Environment (NAME=value per line). They
override the template's env, except its locked names. A disabled schedule keeps its settings and
doesn't fire.
Each fire time is recorded under Fires for 30 days: Started (with the run), Skipped or Failed, with the reason. Runs it started show "From schedule".
Budgets
A fire while the organization's or project's budget stops new runs fails and isn't made up later. Fires in the coming week on a day a budget closes show a Closed by budget warning. See budgets and quotas.
Secrets for one template
A project or organization secret can be restricted to templates: then only runs started from those templates get it. Ad-hoc runs, other templates and run files from a repository don't. See secrets and variables.
Limits
- An organization has at most 50 schedules and 50 Git triggers by default. Its Quotas page shows the limits.
- A template's choice parameter has at most 100 options.