> For AI agents: the complete documentation index is available at https://docs.hod.sh/llms.txt, the full documentation bundle is available at https://docs.hod.sh/llms-full.txt.

# Pipeline reference

A pipeline is the YAML file `.hod/pipeline.yaml` at the root of a repository. This page lists every key the format has, with its type and default; the [Writing pipelines](https://docs.hod.sh/pipelines/events.md) pages explain them, with examples. The format is version 0. Editors can complete and check pipelines with the format's JSON Schema ([Editor support](https://docs.hod.sh/start/editor.md)).

## Rules for every key

- **Unknown keys are errors.** `hod validate` reports each with its `file:line:col`, and suggests the key you probably meant.
- **Keys planned but not built yet** (listed in [Not in v0 yet](#not-in-v0-yet)) fail with `not supported in v0 yet`.
- **Expressions are CEL.** `if:` and `vars:` are expressions as written; every other string field takes a template, `${{ … }}`. They are type-checked when the pipeline compiles ([Expressions and values](https://docs.hod.sh/reference/expressions.md)).
- **No `${{ }}` in `run:`.** Values reach scripts only through `env:`, as variables.
- **Quote** a value that starts with `{`, `[` or `!`, or that contains `: ` (a CEL ternary, say). Single quotes keep CEL's double-quoted strings as they are: `'${{ vars.ok ? "a" : "b" }}'`.
- **Durations** are written like `90s`, `30m`, `1h30m` or `2d`.

## Top level

| Key           | Type               | Default                  |                                                                                                           |
| ------------- | ------------------ | ------------------------ | --------------------------------------------------------------------------------------------------------- |
| `version`     | `0`                | (required)               | The format's version                                                                                      |
| `on`          | list or map        | (required)               | Which forge events start runs ([Events](https://docs.hod.sh/pipelines/events.md#events))                  |
| `vars`        | map of expressions |                          | Named values computed once per run ([Named values](https://docs.hod.sh/pipelines/events.md#named-values)) |
| `concurrency` | `{group, policy}`  | a group per pull request | How runs of this pipeline share a group ([Concurrency](https://docs.hod.sh/pipelines/concurrency.md))     |
| `jobs`        | map of jobs        | (required)               | The jobs, by name ([Jobs](#jobs))                                                                         |

`on:` is a list of event names or a map from names to filters: `push` takes `branches` and `tags`, `pull_request` takes `branches` (the base branch). Filters are globs on the name, where `*` doesn't cross `/`.

## Jobs

| Key             | Type                                       | Default                               |                                                                                                                        |
| --------------- | ------------------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `image`         | template                                   | the runner's default image            | The container image the job runs in ([Jobs and steps](https://docs.hod.sh/pipelines/jobs.md#where-a-job-runs))         |
| `runs-on`       | list of templates                          | any runner                            | Labels the runner must have                                                                                            |
| `needs`         | list of job names                          |                                       | Jobs that must end first ([Order](https://docs.hod.sh/pipelines/jobs.md#order))                                        |
| `if`            | expression (bool)                          | `true`                                | Whether the job runs ([Conditions](https://docs.hod.sh/pipelines/events.md#conditions))                                |
| `env`           | map of templates                           |                                       | Variables for every step                                                                                               |
| `steps`         | list of steps                              | (required)                            | What the job runs ([Steps](#steps))                                                                                    |
| `cache`         | list of presets or `{paths, key_files}`    |                                       | Dependency caches ([Caching](https://docs.hod.sh/pipelines/caching.md#the-dependency-cache))                           |
| `fresh`         | bool                                       | `false`                               | Build from scratch, with no cache ([Caching](https://docs.hod.sh/pipelines/caching.md#what-is-never-cached))           |
| `docker`        | bool                                       | `false`                               | A Docker daemon of the job's own ([Docker in a job](https://docs.hod.sh/pipelines/jobs.md#docker-in-a-job))            |
| `services`      | map of services                            |                                       | Containers beside the job ([Services](#services))                                                                      |
| `matrix`        | map or list of maps                        |                                       | Run the job once per combination ([Matrix](https://docs.hod.sh/pipelines/matrix.md))                                   |
| `fail_fast`     | bool                                       | `false`                               | With `matrix`: a failed instance cancels the others                                                                    |
| `max_parallel`  | int                                        |                                       | With `matrix`: at most this many instances at once                                                                     |
| `concurrency`   | `{group, policy}`                          |                                       | One member of the group at a time ([Concurrency](https://docs.hod.sh/pipelines/concurrency.md))                        |
| `timeout`       | duration                                   | `6h` (the server's `HOD_JOB_TIMEOUT`) | How long the job may run ([Timeouts](https://docs.hod.sh/pipelines/failures.md#timeouts))                              |
| `retry`         | int or list of `{when, exit_codes, max}`   |                                       | Run a failed job again ([Retries](https://docs.hod.sh/pipelines/failures.md#retries))                                  |
| `allow_failure` | `true` or `{exit_codes}`                   | `false`                               | A failure doesn't fail the run ([Allowed failures](https://docs.hod.sh/pipelines/failures.md#allowed-failures))        |
| `secrets`       | list of names or `{name, env}`             |                                       | Secrets for every step ([Secrets](https://docs.hod.sh/pipelines/secrets.md#secrets))                                   |
| `identity`      | `{audience}` or list of `{name, audience}` |                                       | OIDC tokens for every step ([Cloud identity](https://docs.hod.sh/pipelines/secrets.md#cloud-identity))                 |
| `guards`        | list of `{uses, with}`                     |                                       | Components that run for the whole job, such as an egress guard                                                         |
| `uses`          | component reference                        |                                       | Make the job from a template ([Components](https://docs.hod.sh/pipelines/components.md#templates))                     |
| `from`          | path or list of paths                      |                                       | Make the job a group of jobs from files under `.hod/jobs/` ([Job groups](https://docs.hod.sh/pipelines/job-groups.md)) |

A job with `uses` takes only `uses`, `with`, `needs`, `if`, `matrix` and `secrets`. A job with `from` takes only `from`, `needs`, `if` and `matrix`.

### Inside a job's keys

| Key          | In                       | Type                                                        | Default      |                                                       |
| ------------ | ------------------------ | ----------------------------------------------------------- | ------------ | ----------------------------------------------------- |
| `paths`      | `cache`                  | list                                                        | (required)   | Directories to keep                                   |
| `key_files`  | `cache`                  | list of globs                                               |              | Files whose contents make the key                     |
| `group`      | `concurrency`            | template                                                    | (required)   | The group's name                                      |
| `policy`     | `concurrency`            | `buffer_all`, `buffer_one`, `skip`, `cancel_other`, `allow` | `buffer_all` | What a new member does when the group is busy         |
| `when`       | `retry`                  | list of `failure`, `timeout`, `error`                       | all three    | Which endings the rule retries                        |
| `exit_codes` | `retry`, `allow_failure` | list of ints                                                |              | Only failures of a step that exited with one of these |
| `max`        | `retry`                  | int                                                         | `2`          | More attempts this rule allows, at most 10            |

## Steps

| Key             | Type                                           | Default                 |                                                                                                                                  |
| --------------- | ---------------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `run`           | string                                         |                         | The script. One of `run` and `uses`                                                                                              |
| `uses`          | component reference                            |                         | A step component ([Components](https://docs.hod.sh/pipelines/components.md#step-components))                                     |
| `with`          | map of templates                               |                         | The component's inputs                                                                                                           |
| `name`          | string                                         | the script's first line | Shown in logs, the UI and the API                                                                                                |
| `id`            | identifier                                     |                         | Lets later steps read `steps.<id>.outputs` and `steps.<id>.result`                                                               |
| `dir`           | path                                           | the workspace           | Working directory, relative to the workspace                                                                                     |
| `env`           | map of templates                               |                         | Variables for this step, over the job's                                                                                          |
| `if`            | expression (bool)                              | `true`                  | Whether the step runs                                                                                                            |
| `cache`         | `{inputs}`                                     |                         | The step cache: skip the step when its inputs didn't change ([Caching](https://docs.hod.sh/pipelines/caching.md#the-step-cache)) |
| `files`         | list of paths                                  |                         | Files or directories passed to the jobs that need this one ([Files](https://docs.hod.sh/pipelines/files-and-outputs.md#files))   |
| `outputs`       | map of `string`, `bool`, `int`, `list(string)` |                         | Typed values the step writes, one file each ([Outputs](https://docs.hod.sh/pipelines/files-and-outputs.md#outputs))              |
| `push`          | list of ref globs                              |                         | Refs the step may push to ([Pushing](https://docs.hod.sh/pipelines/jobs.md#pushing-to-the-repository))                           |
| `timeout`       | duration                                       | the job's               | How long the step may run                                                                                                        |
| `allow_failure` | `true` or `{exit_codes}`                       | `false`                 | The step's failure doesn't fail the job                                                                                          |
| `secrets`       | list of names or `{name, env}`                 | the job's               | Secrets for this step                                                                                                            |
| `identity`      | `{audience}` or list of `{name, audience}`     | the job's               | OIDC tokens for this step                                                                                                        |

## Services

`name: image` is short for `{image: …}`. See [Services](https://docs.hod.sh/pipelines/services.md).

| Key          | Type                       |                                                                                                                       |
| ------------ | -------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `image`      | template                   | (required) The service's image                                                                                        |
| `env`        | map of templates           | Its variables                                                                                                         |
| `command`    | list                       | Arguments; replaces the image's `CMD`                                                                                 |
| `entrypoint` | list                       | Replaces the image's `ENTRYPOINT`, and drops its `CMD`                                                                |
| `ports`      | list of ints               | Ports to wait for                                                                                                     |
| `ready`      | string or `{run, timeout}` | A script, run in the service with `sh -c`, that exits 0 once the service is ready; `timeout` is 60 seconds by default |

## Limits

|                                   |                                          |
| --------------------------------- | ---------------------------------------- |
| Patterns in `changed()`           | 10                                       |
| Matrix instances per job          | 256                                      |
| Jobs per pipeline, after matrices | 512                                      |
| Group files per pipeline          | 64                                       |
| One group file                    | 1 MiB                                    |
| Attempts one `retry:` rule adds   | 10                                       |
| One output's value                | 16 KiB                                   |
| A job's outputs                   | 64 KiB                                   |
| A secret's value                  | at least 8 bytes                         |
| A job's `timeout:` without one    | 6 hours (the server's `HOD_JOB_TIMEOUT`) |
| A service's readiness             | 60 seconds, unless `ready: {timeout}`    |

## Not in v0 yet

These keys fail with `not supported in v0 yet`:

- at the top level: `inputs`, `registries`;
- in `on:`: `manual`, `api`;
- on a job: `environment`, `resources`, `checkout`, `post`;
- on a step: `reports`, `annotate`, `image`.

Also not built yet: `paths` filters in `on:` (use `changed()` in `if:`), matrices built from a job's outputs, and services for a single step.
