Skip to content

Variables and secrets reference

A mapping of variable names to values. It is allowed at the top of a flow, on a job and on a step, and in truss.yaml for the whole project.

env:
STAGE: nightly
RETRIES: 3 # the text "3"
  • A later level wins: step over job over flow over project over the environment the run started in.
  • Values are text. A name starts with a letter or _, then letters, digits or _.
  • Do not put secrets in env: the file is plain text. Use secrets.

A value of env, and a dir or workdir, can use other variables:

truss.yaml
env:
DATA: ${HOME}/data
# .truss/flows/sync.yaml
env:
INBOX: ${DATA}/inbox
PATH: ${TRUSS_PROJECT_DIR}/bin:${PATH}
steps:
- id: sort
dir: ${INBOX}
run: ./sort-photos
  • ${NAME} takes its value from the same level, a lower level, the built-in variables, or the environment TRUSS started in. A variable that is not set gives an empty text.
  • ${NAME} inside the value of NAME itself means the value from below, so PATH: ${TRUSS_PROJECT_DIR}/bin:${PATH} adds to your PATH.
  • The order inside one level does not matter. Two variables that use each other fail the step before it starts.
  • $$ is a literal $. A $ before anything else stays as written, so $HOME is left for the shell of the step.
  • A dir that uses an unset variable fails the step, rather than running somewhere else.
  • Stored secrets are never expanded: ${TOKEN} does not copy a secret into another variable.
  • On the command line, --env NAME=VALUE is taken as written and wins over the file. It may set a built-in variable, to try a step as the daemon would run it.

TRUSS sets these in every run, however it started. A file may not set them (truss validate says so), and they win over a variable of the same name in your environment.

Variable Value
TRUSS_FLOW The flow’s name.
TRUSS_STEP The step’s id as written in the file.
TRUSS_JOB The job’s id. Set only for a step of a job.
TRUSS_ATTEMPT 1, then 2 and up for each retry.
TRUSS_RUN_ID The run’s id. A local run the daemon does not track gets local-<time>-<random>.
TRUSS_TRIGGER manual, schedule, catch-up, file, run, or local for truss run.
TRUSS_PROJECT_DIR The project folder.
TRUSS_TEMP_DIR A folder for this run only, removed when the run ends.
TRUSS_CHANGED_FILES For a run started by on.file: a file that lists the changed paths.
TRUSS_OS, TRUSS_ARCH linux, darwin or windows; amd64 or arm64.
TRUSS_DATA_DIR, TRUSS_CACHE_DIR Folders that outlive runs (see below). A file may set these two.
TRUSS_PIPELINE The same as TRUSS_FLOW, under its older name.

Other names starting with TRUSS_ are yours to use, but later versions may add built-ins. Pick another prefix to be safe.

Every run gets two folders that outlive it. TRUSS creates them before the first step and never empties them.

Variable truss run A run of the daemon
TRUSS_DATA_DIR .truss/state/<name>/data in the project ~/.truss/pipelines/<name>/
TRUSS_CACHE_DIR .truss/state/<name>/data/cache ~/.truss/pipelines/<name>/cache

They are plain folders: a package cache, a downloaded tool. TRUSS has no cache keys and does not save or restore anything. truss cache clear <name> empties a cache folder.

A list of secret names, allowed at the top of a flow, on a job and on a step. Each name must be stored first with truss secret set <name> (command reference).

secrets: [GITHUB_TOKEN] # every step
jobs:
publish:
steps:
- id: npm
run: npm publish
secrets: [NPM_TOKEN] # this step only
  • A declared secret becomes an environment variable of the same name in the steps that declare it (directly, or through their job or the flow), and in no other step. It wins over an env entry of the same name.
  • A secret that is not stored fails the run before any step starts. The error lists the missing names and says truss secret set <name>.
  • Names follow the rule for env names. A repeated name, or a value that is not a list of strings, is an error. truss validate lists the secrets a step uses and does not read the store.
  • A flow that declares no secret never reads the store.

In a run of a flow that declares secrets, every stored value (not only the declared ones) is replaced by *** in the run log, the saved run.log, the daemon’s log, and TRUSS Desktop. A value split over several output chunks is still caught.

Redaction is exact text matching. It cannot catch a value that a step encodes or transforms (base64, hex, upper case, reversed), splits across lines, writes to a file, sends over the network or hands to another program’s own log. A very short secret is replaced wherever it appears, which can garble other output. Do not print secrets from a step, and do not run set -x or env in a step that has them.

The store is the file secrets.json in the TRUSS home. It is not encrypted. See Variables and secrets.