Pipeline file reference
The complete reference for .branchd/pipelines/*.yaml on one page, with every key, what it takes, what is refused, the job token, superseding, other repositories and presets. Also served as Markdown at /docs/branchd/pipelines/reference.md.
Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its
.forge-ci.yamlor.xeonr-ci.yaml. See What is available.
This page is the whole language on one page, and is served as Markdown at
/docs/branchd/pipelines/reference.md
for agents. Expressions,
Step files,
Limits and
Refusals go into more detail. The
JSON Schema is generated from the same key
tables as the compiler. The compiler is xeonr/forge/ci v1.20.0.
Files
- Each file in
.branchd/pipelines/ending in.yamlis one pipeline. A file ending in.ymlis refused. - Each file is compiled on its own; a refused file does not stop the others.
- A repository with
.branchd/pipelines/and an older CI file (such as.xeonr-ci.yaml) beside it is refused. - YAML anchors and aliases (
&x,*x,<<: *x) work. - A repository that branchd has not switched to pipeline files ignores
.branchd/pipelines/and runs its old files. - One commit holds at most 50 pipeline files.
Check names
Each job reports a check on the commit, <pipeline> / <job>, the job as the
file names it:
| Job | Check |
|---|---|
| a job | CI / build |
| a matrix cell | CI / test (1.26, linux), CI / cell (1, x) |
| a job of a called pipeline | CI / deploy / plan |
| a preset's job | CI / preset.apps.api.build |
| an isolated step's earlier parts | CI / build [1/2]; the last part is CI / build |
any job of the pipeline named exactly ci | build, without ci / , as the old files' checks were; but ci / lib / prep when the job's name holds / |
A branch rule's required check is written the same way, and keeps matching while the file names the job the same.
Push checks
A push that changes .branchd/pipelines/, .branchd/steps/ or
.branchd/packages.yaml is checked before it is accepted: each changed
pipeline file is compiled for the push's own run (or its pull request's)
and for every event its on: lists, with branch, tag, path, schedule
and from: filters treated as matching (a push to a branch and of a tag, a
pull request, each schedule up to three, manual and trigger with each
input's default, and for on: call a job of this repository calling it).
- A file the push breaks refuses the push, with
file:line:column: messagelines. A file that failed the same way at the branch's previous tip is a warning, so a revert or an old branch can always be pushed. Only the tip of each pushed branch is judged. - Only what a file itself gets wrong refuses (syntax, unknown keys, expressions, limits, needs cycles, steps of this repository that do not exist). What depends on another repository is a warning.
- The check fails open: if it cannot run in time, the push goes through with a line saying so.
git push -o ci.allow-invalidlets a broken file through, for those who may bypass the branch's rules; the push is recorded as bypassed.branchd ci lint(0.39.0 and later) runs the same every-event check locally.
Top-level keys
| Key | Takes | Meaning |
|---|---|---|
name | string | The pipeline's name, 1 to 64 characters, no /. Default: the file name without .yaml. Unique in the repository. Checks are named <name> / <job>. |
on | event, list, or map | When it runs. Required. See on. |
env | map | Environment for every job. May read inputs.*. |
defaults | {image, runs-on} | The image and runs-on of jobs that set neither. |
max-parallel | Refused for now: branchd cannot yet limit how many jobs of a run run at once. | |
concurrency | {group, cancel-in-progress} | With group, the repository's runs in the group never overlap: a newer run waits for the older, or cancels it with cancel-in-progress: true (GitHub's concurrency group). Without group, true lets a newer run cancel this pipeline's runs on a protected branch too, and false stops newer runs cancelling or queueing behind them. See Superseding. |
permissions | map | What the job token may do, for every job that does not set its own. See The job token. |
preset | {uses, with, secrets, allow, runs-on, permissions} | The jobs of a preset of another repository. See Presets. |
jobs | map of ids to jobs | Required, at least one, unless the file has a preset. See Job keys. |
on is required unless the file has a preset, whose default triggers it
then narrows.
Refused: max-parallel; and
the GitLab CI keys stages, variables (use env), default (use
defaults), workflow (use on), include (use uses) and schedules
(use on: schedule).
on
on: is an event (on: push), a list (on: [push, pull_request]), or a map
of events to their keys. A run is for one event. A file whose on: does not
match the event has no run, and branchd ci plan says why.
| Event | Keys | Runs when |
|---|---|---|
push | branches, tags, paths | A push of a branch or a tag. With only branches, tags never run it; with only tags, branches never do; with neither, both do. paths is not read for a tag. |
pull_request | paths | A pull request's run, for each new head. |
schedule | list of {cron, name, ref} | A scheduled run of one of the file's schedules. |
manual | inputs | A person starts this pipeline. |
trigger | from (required), inputs | Another repository's trigger: job starts it. |
call | inputs, secrets, outputs | Never on its own: a job's uses: brings this file's jobs into its run. See Reusable pipelines. |
-
branches,tags,pathsare a glob or a list of globs.*matches within one path segment,**across segments;?,[…]and{a,b}work. A leading!excludes, and the last pattern that matches decides.pathsholds when any changed path matches. A new branch, a tag, or a push with more changes than branchd lists counts as everything changed. -
schedule:cron(required) is five fields in UTC, firing at most every five minutes.nameis letters, digits,.,_and-, at most 64, unique in the repository; default<file name>-<n>.refis a branch; empty is the default branch. At most 10 a file and 50 a repository. branchd keeps the schedules in line with the files on the default branch; each fire runs the file onrefat its newest commit. -
trigger.from:organisation(any repository),company(repositories of teams the same company owns as this repository's), or a list of repository paths. It is read from the default branch's file. A repository triggering its own pipeline must list itself. -
The merge queue. A merge-queue commit is a
pushto its target foron:alone, soon: push: branches: [main]runs on it. Its jobs see the queue's ref:branchis empty,protectedfalse,merge_queuetrue, so a deploy gated onbranch == 'main'is left out of it. -
inputs(undermanual,triggerandcall) map names to{type, options, default, required, description}:type:string(default),boolean,numberorchoice;options: the values of achoice, which needs them (and only achoicetakes them);default: the value when none is given;required: a value must be given when there is no default;description: for people.
A run's inputs are checked against the types before it starts. An input the file does not declare is refused. On any other event an input reads its default, else
'',falseor0. A name declared under bothmanualandtriggermust have one type. Two input names that differ only in case,-and_are refused. -
call.secretsmap names to{required, description}.call.outputsmap names to${{ jobs.<id>.outputs.<name> }}, or{value, description}.
Job keys
A job id is letters, digits, _ and -, starting with a letter or _. Ids
starting with preset. are reserved. Two ids that differ only in - and
_ are refused.
| Key | Takes | Meaning |
|---|---|---|
steps | list of steps | The job's steps. Required unless the job has uses or trigger. See Step keys. |
uses | string | Instead of steps: call a reusable pipeline, ./<path>.yaml or <group>/<repo>/<path>.yaml@<version>. See Calling jobs. |
with | map | The called pipeline's inputs. Only with uses. |
allow | list: environment, trigger | Only with uses of another repository: what it may choose for this run. See Consent. |
needs | id, list of ids, or {job, optional, artifacts} | The jobs this one waits for, which must succeed. optional: true: the need is dropped when that job does not run for this event, and is an ordinary need when it does. artifacts: false: wait without downloading its artifacts. A need on a matrix job waits for each of its cells. A need on a job that does not run is refused unless optional. Needs name jobs of the same file only. |
if | expression | False leaves the job out, with the reason. Decided when the run is compiled. It may use always() (run even after a failed need) and success(), not failure(). It may not read outputs. |
matrix | map | One job per combination. See matrix. |
trigger | map | Start a run of another repository's pipeline. See trigger. |
image | string | The container image the job's run: steps run in. Required for a run: job, here or under defaults. A whole ${{ needs.<job>.outputs.<name> }} of a typed step's job runs in an image built earlier in the run. |
runs-on | string or list | Runner labels. The label deploy is reserved for branchd's own deploy steps. |
services | map of aliases | Containers beside the job: an image, or {image, env, command, entrypoint, ports}. The alias is the service's host name. |
env | map | Environment for the job's steps. |
outputs | map | Values the jobs that need this one read as ${{ needs.<job>.outputs.<name> }}. Each is one line. A matrix job has none. |
artifacts | list of paths, or {paths, when, expire-in} | Files kept after the job and placed in each job that needs it. when: success (default), failure or always. A path that is, holds or could match .branchd/run/ (., *, **, .branchd) is refused. |
cache | {key, files, paths, policy, when, fallback-keys}, or a list | paths (required) are kept between runs. files keys the cache on those files' contents, with key as the prefix. policy: pull-push (default), pull or push. when: success (default) or always. fallback-keys are tried when key has none. |
secrets | list of names, or map of names to {type, target} | The secrets granted, as environment variables. target renames the variable; type is env (default) or file (a file secret; its path arrives in target). A listed secret set nowhere fails the job's attempt; a step's optional secret is skipped instead. |
checkout | false, or {depth, tags, submodules} | The checkout is automatic and needs nothing in the image, not even git. depth defaults to 50; 0 is the whole history. tags: true fetches tags. submodules: true checks out the submodules, recursive theirs too; a submodule must be readable without a credential (public, or internal on branchd), since the job token reads this repository only. false leaves the working directory empty. |
repository-code-secrets | boolean | Allows typed steps that execute repository code to receive secrets whose policy permits the step package. Anyone who can change that code can access those secrets. |
permissions | map | What the job's token may do; replaces the file's. See The job token. |
environment | name, or {name, url} | Record a deployment to this environment. |
concurrency | lock name, or {group, cancel-in-progress} | group: one job holding the lock runs at a time in the repository; others queue. cancel-in-progress: true: a newer run may stop this job part-way; false: never. Unset, the run's default decides (Superseding). |
manual | true, or {wait, on-expiry, blocking} | The job waits for a person to release it. wait: how long (24h); on-expiry: fail or skip; blocking: false: the run may finish without it. |
timeout | duration | How long the job may run: 10m, 1h30m, 1 hour. |
resources | {cpu, memory} | What the job's step asks for: cpu in cores (2, 0.5) or millicores (500m), memory as 8Gi or 512Mi. Only a runner pool whose job sizes hold the request takes the job; one no pool can hold fails no_worker. A host job takes none. |
host | true | The job's steps run in the shell of a runner's own machine, with no image or container. |
retry | number, or {max, when} | Retry a failed job up to max times (0 to 10). when lists failure kinds: always, script_failure, stuck_or_timeout_failure, job_execution_timeout, runner_system_failure, unmet_prerequisites, missing_dependency_failure, api_failure, scheduler_failure, unknown_failure, data_integrity_failure, downstream_failure. |
continue-on-error | true, or {exit-codes: […]} | The job may fail and the run goes on; with exit-codes, only for those codes. |
Refused: the GitLab CI job keys, each with its
replacement: script (steps), before_script (the first steps),
after_script (a last step with if: always()), stage (needs), rules
and when (if, or manual: true), variables (env), allow_failure
(continue-on-error), resource_group and lock (concurrency), tags
(runs-on), parallel (matrix), extends (uses, or YAML anchors),
interruptible (concurrency: {cancel-in-progress: true}) and
module_token.
Step keys
| Key | Takes | Meaning |
|---|---|---|
id | id | Names the step in its job; its outputs are steps.<id>.outputs.<name>. Unique in the job. |
name | string | What the log shows. |
run | string | Shell commands. A step has run or uses. |
uses | string | A composite step, ./<name> (.branchd/steps/<name>/step.yaml) or <group>/<repo>/<path>@<version>; or a typed step, ci/<name>@<version>, as the job's only step. |
with | map | The inputs of what uses names. |
if | expression | always(), failure(), success(), and anything decided when the run is compiled. Without a status function it holds only while no step has failed. It may not read outputs. |
env | map | Added to the job's environment for this step. |
working-directory | path | Where the step runs, relative to the workspace and inside it. |
shell | bash or sh | Run the step in that shell. Unset: the job's shell. |
timeout | duration | The step fails when it runs longer. |
continue-on-error | boolean | The job goes on if the step fails. |
isolated | boolean | true runs the step as a node of its own, a part of the job. Required for a typed step among other steps. See Isolated steps. |
workspace | all, or a list of paths | On an isolated step: what it receives from the steps before it, and hands back. Left out, the checkout only. |
How steps run.
- A job's
run:steps share one shell, bash when the image has it, else sh, withset -e(and-o pipefailunder bash). Acdor anexportin one step is seen by the next. - A step with
env,working-directory,shell,timeoutorcontinue-on-errorruns in a subshell of its own: its changes do not reach later steps.shellandtimeoutstart a new shell, which sees exported variables only. - When a step fails, the steps after it with
if: always()orif: failure()still run, each in a subshell, and the job fails with the first failure's exit code. When the job is cancelled, itsif: always()andif: cancelled()steps run after the cancel, in a fresh shell (Cancelled jobs). - In a job with such a step, a step that sets or clears the shell's EXIT trap
is refused. Set it inside a subshell,
( trap 'rm -f x' EXIT; make ), or give the step ashell:of its own. - A step writes outputs as
name=valuelines to$BRANCHD_OUTPUT.
A typed step, uses: ci/<name>@<version>, is a step that branchd
provides, run in its own image. As its job's only step it takes id,
name, uses, with, env, timeout and continue-on-error, its job
takes no image or checkout, and its if: goes on the job. Among other
steps it must be isolated: true, and also takes if, isolated and
workspace. @1 or @1.0 is the newest version with that prefix; @1.0.1
is exact. Its job's outputs: pass its outputs on, and they reach a
dependant's image: and with:.
A step published by a product, uses: strata/migrate@1, is a typed
step that the product publishes from its own repository and versions with
its own releases. The name resolves only through branchd's binding of the
namespace (strata) to the one repository that may publish into it
(xeonr/strata/cli), set by branchd and never by a pipeline file or the
product's repository: the step is the step.yaml in steps/migrate there,
at the newest v1.x.y tag, and it must name exactly strata/migrate. It is
also written by its path, xeonr/strata/cli/steps/migrate@v1. It gets only
what the job grants it (secrets: and identity: on the step), each of
which its step.yaml must declare. The run records the repository, tag,
commit and version each one resolved to, and the registry digest of that
version, and branchd refuses to start a run naming a product step that was
not read from its namespace's repository.
Not yet available (product steps): no namespace is bound yet, so
uses: strata/migrate@1is refused with a message saying so. Binary steps of your own repository are not available either.
A composite step's use takes id, name, uses, with, if, env,
isolated and workspace. See Composite steps
and Step files.
Isolated steps
A step marked isolated: true runs as a node of its own; the job is split
into parts around it, chained by needs:. Full guide:
Isolate a step from the job.
workspace:lists globs relative to the working directory (at most 32,dir/**for a tree;.gitonly if listed), orall; left out, the step gets the checkout only and hands nothing back. A step that takes no source can be givenallor nothing.- What it writes inside those paths comes back; nothing outside the working directory, no exported variable, service or background process crosses. Step outputs cross.
- Refused:
if: failure()on an isolated typed step,continue-on-errorand aconcurrencylock on the job, more than 8 isolated steps in a job. - It gets only the secrets its package declares, and its identity tokens reach no other part.
matrix
| Key | Meaning |
|---|---|
<key>: [values] | One dimension. The job runs once per combination of all dimensions. |
include | A list of maps. Each joins every combination whose values it agrees with, adding its other keys; one that agrees with none is a combination of its own. |
exclude | A list of maps. Each removes the combinations it matches. |
fail-fast | true (the default): once a cell fails, the others stop. false: every cell runs to its end. |
A cell is named <id> (<values>), such as test (1.26, linux). Values are
read as ${{ matrix.<key> }}, and each cell's if: is decided on its own.
A matrix job has no outputs. At most 256 cells; the product of the
dimensions may be up to 1,024 before exclude; include and exclude take
up to 256 entries each.
trigger
| Key | Meaning |
|---|---|
repo | The repository to start a run in. Required. |
pipeline | The name of the pipeline there (.branchd/pipelines/<pipeline>.yaml). |
ref | A branch there; empty is its default branch. |
inputs | Its on.trigger.inputs. |
wait | true: this job takes the other run's result. |
The target must declare on: trigger with a from that allows this
repository. A trigger job takes only trigger, needs, if, matrix,
environment, concurrency, manual and continue-on-error.
Calling jobs
A job with uses: calls a reusable pipeline (a file with on: call). It
takes uses, with, needs, if, secrets, allow, runs-on,
environment, concurrency, manual and matrix, and runs nothing itself.
With matrix, the pipeline is called once per cell, its jobs named
<calling job> (<values>) / <job>, and with: and if: read matrix.*.
- The called jobs join the run as
<calling job> / <job>. if:false leaves them all out;always()lets the first of them run after a failed need.needs:are what the called pipeline's first jobs wait for. A job that needs the calling job needs every called job.with:giveson.call.inputs: an input it does not declare, or a missing required one, is refused. A whole${{ needs.<job>.outputs.<name> }}of a job it needs passes that output to astringorchoiceinput.secrets:lists the secrets passed; each must be inon.call.secrets, and every required one must be passed.environment:,concurrency:andmanual:are set on every called job. A called job that also setsenvironmentorconcurrencyis refused; the caller'smanualreplaces a called job's own.- Dependants read
on.call.outputsas${{ needs.<calling job>.outputs.<name> }}. - A called pipeline's expressions read the run's facts, its inputs, its own
env:and its own jobs;varsis refused there. Its top-levelconcurrencyapplies only when it runs on its own. - The calling file's
env:and the repository's settings variables reach a called pipeline of the same repository, and not one of another repository. matrix:on a calling job is refused.
Consent
For a pipeline of another repository, the calling job decides:
- an
environment:on one of its jobs needsallow: [environment]; - a
trigger:job in it needsallow: [trigger]; - each runner label it asks for (
runs-on, or itsdefaults.runs-on) must be listed in the calling job'sruns-on, which lends labels without setting them; - a call inside it is allowed only what every calling job above it allowed.
A pipeline of the calling repository may set all of these.
Other repositories
uses: of a step, <group>/<repo>/<path>@<version>, or of a pipeline,
<group>/<repo>/<path>.yaml@<version>, reads another repository when the
run is compiled. Full guide:
Steps and pipelines of another repository.
- The form has at most 8 parts. The shortest leading part of at least two
that is a repository you may read is the repository
(
xeonr/forge/steps/setup-buf@v1issetup-bufinxeonr/forge/steps). - Versions are tags, resolved to a commit at compile time:
@v1the newestv1.x.y,@v1.4the newestv1.4.y,@v1.4.2exactly,@1for tags withoutv; a 40-character commit only if a version tag names it or the default branch reaches it. A branch (@main) is refused. Only[v]X.Y.Ztags count (v1.5.0-rc1never does). .branchd/packages.yamlat the head of the publisher's default branch lists the step directories, pipeline files and presets others may use; anything else is refused. Inside a used step,./<name>is the publisher's own.branchd/steps/<name>.- Who may use it is the publisher's visibility, judged for the calling repository: private, that repository only; company, repositories of the same company's teams; organisation, every repository; public, anyone. A repository you may not read is refused exactly as one that does not exist. A nested reference must be readable by every repository in the chain.
- Trust. A used step runs in your job's shell with its secrets, job
token and workspace; a used pipeline is that team's jobs running as your
repository with the secrets you pass.
branchd ci planlists each with the tag and commit it resolved to. - Consent. A called pipeline of another repository may set
environment:only withallow: [environment]on the calling job, starttrigger:jobs only withallow: [trigger], and ask only for runner labels the calling job'sruns-onlists. - At most 32 distinct references to other repositories in a run, and 1,000 version tags of one major per repository.
Presets
preset: {uses: <group>/<repo>[/<path>]@<version>, with: {...}} runs a
preset, a WebAssembly program in another repository
(<path>/preset.wasm, listed in its packages.yaml), and adds the jobs it
returns. Full guide: Presets.
- One preset a file.
uses: ./<path>, a preset of the same repository, is refused for now. - Its jobs are at addresses under
preset.:preset.apps.api.build(checkCI / preset.apps.api.build, nodepreset_apps_api_build). A prefix is a group:needs: [preset.apps.api], orneeds: [preset]for all of it. - A need on one preset job that does not run here is refused unless
optional: true. Its outputs are${{ needs.preset.<address>.outputs.<name> }}, or${{ preset.<address>.outputs.<name> }}in any job that waits for it. on:is optional; the file's ownon:only narrows the preset's default triggers, and an event the preset does not trigger on is refused.- Nothing in the file redefines a preset job: change
with:. - Its jobs have the repository's full context (secrets, environments,
triggers, runner labels,
permissions:).secrets: [...],allow: [environment, trigger],runs-on: [...]andpermissions: {...}underpreset:narrow what they may use. - A push runs at most 8 presets, 15 seconds of module time in all.
The job token
Every job gets BRANCHD_TOKEN. git uses it with no set-up; the API takes
it as a bearer token (POST $BRANCHD_API_URL/xeonr.forge.v1.<Service>/<Method>,
JSON, lowerCamelCase fields). It reads this repository only. Full guide
with curl examples: The job token.
| Permission | read | write |
|---|---|---|
contents | Always: commits, trees, branches, tags, git fetch | git push, branches and tags |
pull-requests | Pull requests, diffs, reviews, comments | Comment, resolve, a comment-only review, open, edit, close, reopen |
checks | Checks on commits | Report an external check |
releases | Releases and files | Create, edit, delete, upload |
packages | List and pull images | Push images |
pipelines | Runs, logs, plans | Start, retry, cancel runs |
permissions:at the top is every job's default; a job's own replaces it; with neither,contents: read. An unknown name or level, or an emptypermissions:, is refused.contents,releasesandpackageswrites need a protected ref and a push or manual run by a person, an agent or the team's own bot. A scheduled or triggered run only reads them.- On a pull request's run and any unprotected branch, writes are capped by
the repository's ceiling (default
pull-requests: write,checks: write, on that pull request and commit). - Never: settings, variables, secrets, branch rules, members, visibility; approving, merging or queueing a pull request; releasing a manual job; another repository.
- A called pipeline's jobs get at most the calling job's permissions. A composite step has the using job's.
- Variables:
BRANCHD_TOKEN,BRANCHD_TOKEN_COMMAND(prints a fresh token),BRANCHD_API_URL,BRANCHD_REPOSITORY,BRANCHD_PR.
Superseding
A newer run of the same pipeline for the same pull request or branch supersedes the older run. Runs of different pipelines never do.
| The older run is for | By default | concurrency: {cancel-in-progress: true} at the top | … false at the top |
|---|---|---|---|
| a pull request | cancelled, its running jobs stopped | cancelled | runs side by side |
| a push to an unprotected branch | cancelled, its running jobs stopped | cancelled | runs side by side |
| a push to a protected branch | runs to the end; the newer run queues behind it | cancelled | runs side by side |
| a tag | runs side by side (each tag is its own ref) | side by side | side by side |
| a manual, scheduled or triggered run | never superseded | never | never |
- Never stopped part-way, whatever the default: a job with
environment:(unless it sayscancel-in-progress: true), a job whose typed step is not safe to interrupt (a deploy, a migration, a publish), and a job withconcurrency: {cancel-in-progress: false}. Once one of those has started, the older run is not cancelled at all: it finishes, and the newer run queues behind it. - A cancelled run's checks say
cancelled, "superseded by run #N", neverfailed. A pull request's required checks are judged on its head commit only. - A rollback is just a newer run: on a protected branch it queues behind the run in progress.
Expressions in brief
Everything in ${{ }} and if: is decided when the run is compiled, except
steps.<id>.outputs.<name> and needs.<job>.outputs.<name>, which are read
while the job runs (in run:, env:, image:, with: and job
outputs:, and in if:: a step's if: is decided when the step's turn
comes, a job's when its needs have run). Contexts: branch, tag, event, pr.number,
pr.source, pr.target, inputs.*, matrix.*, vars.*, env.*, sha,
ref, repository, default_branch, protected, merge_queue,
preset.<address>.outputs.*. Functions: changed(), exists(),
contains(), startsWith(), endsWith(), always(), success(),
failure(), cancelled(). A ${{ }} in a run: becomes an environment variable, never
shell text. Details: Expressions.
Not available yet
Each is refused with a message saying so, or documented as missing:
max-parallel.- A
run:job's outputs as animage:or a typed step'swith:. - A preset of the same repository (
./<path>). - Steps published by other products; binary steps of your own repository.
- A trigger of another repository that is not yet switched to pipeline files (today, every other repository).
- The shared
xeonr/forge/stepsandxeonr/forge/presets, from any other repository: released (v1), but still private. - A step-level
secrets:for an isolated step.