> 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.

# Job groups

When `.hod/pipeline.yaml` grows, move jobs into files under `.hod/jobs/` and keep only the wiring in the pipeline. A job with `from:` is a **group**: its jobs come from one file, or a list of files, and are named `<group>/<job>`, even when there's only one.

```yaml file="<root>/examples/groups/.hod/pipeline.yaml"
# The wiring: which events start a run, and how the groups depend on
# each other. The jobs themselves are in .hod/jobs/.
version: 0
on: [push, pull_request]
jobs:
  plan:
    image: alpine:3.22
    steps:
      - run: echo true > "$HOD_OUTPUTS/run_checks"
        outputs: {run_checks: bool}
  lint:
    from:
      - ./.hod/jobs/lint/rust.yaml
      - ./.hod/jobs/lint/js.yaml
    needs: [plan]
    if: jobs.plan.outputs.run_checks
  test:
    from: ./.hod/jobs/test.yaml
    matrix: {rust: ["1.90", "1.91"]}
  release:
    from: ./.hod/jobs/release.yaml
    needs: [lint, test]
    if: has(event.semver)

```

```yaml file="<root>/examples/groups/.hod/jobs/test.yaml"
jobs:
  unit:
    image: 'rust:${{ matrix.rust }}'
    steps:
      - run: cargo test --lib
      - run: |
          if [ -d tests ]; then echo true; else echo false; fi > "$HOD_OUTPUTS/has_tests"
        outputs: {has_tests: bool}
  integration:
    # A sibling, by its short name: test/unit.
    needs: [unit]
    if: jobs.unit.outputs.has_tests
    image: 'rust:${{ matrix.rust }}'
    steps:
      - run: cargo test --test '*'

```

The run has the jobs `plan`, `lint/clippy`, `lint/fmt`, `lint/eslint`, `test/unit (1.90)`, `test/unit (1.91)`, `test/integration (1.90)`, `test/integration (1.91)` and `release/publish`.

## The entry

The job with `from:` sets only `from`, `needs`, `if` and `matrix`. Its `needs:` and `matrix:` apply to every job of the group, and its `if:` is ANDed into each job's own. Everything else is set on the jobs in the files: `image:` next to `from:` is an error that names the files.

Paths start with `./`, are written from the repository root, and point at a `.yaml` or `.yml` file under `./.hod/jobs/` (subfolders allowed). A symlink must lead to a file under `.hod/jobs/` too. A path listed twice, a missing file and a file with no jobs are errors.

## The files

A group file has one key, `jobs:`. Its jobs take every job key but `from` (groups don't nest) and `uses` (call templates from `.hod/pipeline.yaml`); step components work as anywhere else. A job name used in two files of one group is an error.

## Names

Inside a group's files, a job names the others in its group by their short names, in `needs:` and in expressions: `jobs.unit.outputs.has_tests` in the example means `test/unit`. Other jobs go by their full names: `needs: [plan]`, `needs: [test/unit]`, `jobs["test/unit"].result`. Needing a job outside the group whose name a job inside also has is an error: rename one of them.

- **Needing a group**, as `release` does, waits for all of its jobs. A job inside a matrix group that needs a sibling waits for every instance of it.
- **One file in several groups**, each with its own `if:`, `needs:` or `matrix:`, gives each group its own copies of the jobs (`lint-pr/clippy`, `lint-main/clippy`). An error in the file is reported once.
- A group takes no inputs and reads what any job reads: `event`, `vars`, its `matrix`, and the jobs it needs. For arguments, write a template ([Components](https://docs.hod.sh/pipelines/components.md)).
- `hod plan` shows each job's file (`from ./.hod/jobs/test.yaml`), `hod logs --job test` shows the log of every job of the group, and `hod schema jobs` prints the group files' JSON Schema ([Editor support](https://docs.hod.sh/start/editor.md)).
