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, and this page is available as Markdown at https://docs.hod.sh/reference/expressions.md.

Expressions and values

Expressions are CEL. if: and vars: are expressions as written; every other string field takes a template, ${{ … }}, whose value is put into the string. Expressions are type-checked when the pipeline compiles. There is no ${{ }} in run:: values reach scripts only through env:.

What an expression can read

NameWhere
eventeverywhere but runs-on, which reads only matrixThe event that started the run (below)
vars.<name>everywhere but runs-on and earlier varsNamed values (Events and conditions)
matrix.<key>in a matrix jobThe instance's values, as strings (Matrix)
jobs.<name>.resulta job's if:"success", "failure", "cancelled" or "skipped", for the jobs in its needs:
jobs.<name>.outputs.<output>jobs that need itTyped outputs (Files and outputs)
steps.<id>.outputs.<output>, steps.<id>.resultlater steps of the job

Functions

  • has(event.pull_request) tests whether a field is set. Reading a field that isn't set is an error when the expression runs.
  • changed("src/**", "go.mod") is true when a changed file matches one of up to ten patterns (the rules of cache.inputs), and when Hod doesn't know what changed: tags, manual and scheduled runs, and hod local run without --changed. Its arguments must be string literals.
  • event.semver is set for tags that are versions: an optional prefix ending in / or @, an optional v, then a semantic version.
  • The CEL strings and bindings extensions are on: s.startsWith("x"), s.split("/"), list.join(","), cel.bind(…).
  • An expression too costly to run (over 1,000,000 cost units, by its estimate) is rejected when the pipeline compiles, and evaluation is bounded at run time.

Values Hod gives you

In expressions the event is event, and in every step's environment Hod sets the variables in the last column:

Event fieldExampleEnvironment variable
event.type"push", "pull_request", "tag", "manual", "schedule"HOD_EVENT
event.ref"refs/heads/main"HOD_REF
event.sha"3f9c2a1…"HOD_SHA
event.short_sha"3f9c2a1"
event.branch"main" (pushes, scheduled runs, and manual runs on a branch)HOD_BRANCH
event.is_default_branchtrue for a push to the default branch
event.tag"v1.2.0" (tags only)HOD_TAG
event.name"nightly": the schedule's name (scheduled runs only)HOD_SCHEDULE
event.semverset for version tags: prefix, major, minor, patch, prerelease, build, version ("1.2.0-rc.1", without v or prefix)
event.before_shathe commit before a push
event.changed_files["src/app.ts"]
event.commit_messagesthe pushed commits' messages
event.repositoryfull_name, default_branch, forge
event.actorlogin
event.pull_requestset for pull requests: number, title, base_branch, head_branch, from_fork, draft, labelsHOD_BASE_BRANCH (base_branch)

Steps also get CI=true, HOD=true, HOD_JOB, HOD_RUN_ID, HOD_RUN_ATTEMPT, HOD_WORKSPACE, HOD_OUTPUTS (the directory a step writes its outputs to), HOD_SECRETS (the directory holding the step's granted secrets, one file each) and, for a step granted identity, HOD_IDENTITY_TOKEN_FILE. Hod's own variables (HOD and the HOD_* names in this section) can't be set in env:; other names, such as HOD_SERVER for a job that calls hod, can.