errand block
Theerrand block sets playbook-level configuration. It is optional and can appear at most once across all .ern files.
Attributes
The default working directory for all tasks in the playbook. Tasks with their own
working_dir override this value. Relative paths are resolved from the directory where errand was invoked.Example
test and build run from ./service/api without repeating working_dir in each task.
Notes
- If no
errandblock is declared, tasks run from the directory whereerrandwas invoked unless they specify their ownworking_dir. - Declaring
errandmore than once is an error.
variable block
Variables are named inputs. Declare them in the playbook and pass values at run time with--var. Reference them as var.<name>.
default is required: Errand reports an error if no value is provided.
Attributes
A human-readable description shown in error messages.
A type constraint. When set, Errand validates and converts the provided value. See types for all available types.
The value used when no
--var flag is passed. Must be compatible with type when both are set.Passing values
--var flags are supported. Values are strings on the command line and converted to the declared type automatically.
Examples
Required variable, no default means it must be supplied:port field is omitted, so its default 5432 applies.
Boolean variable used in a conditional command:
Notes
- Variable names must be unique across all
.ernfiles in the playbook. - Access object fields with dot notation:
var.db.host. - Access list elements by index:
var.services[0].
computed block
Acomputed block evaluates an expression at runtime and makes the result available as computed.<name>. Use it to derive values from variables, the environment, or built-in functions without duplicating logic across tasks.
expression is required. description is optional.
Attributes
A human-readable description of the computed value.
The expression to evaluate. Can reference variables (
var.<name>), call built-in functions, and combine values with string interpolation.Evaluation order
Computed blocks are evaluated before tasks run, in dependency order. If acomputed block references a variable, that variable is resolved first automatically. If two computed blocks reference each other, Errand reports a cycle error.
Examples
Read from the environment with a fallback:image_tag depends on version, so Errand evaluates version first:
Notes
- Computed names must be unique across all
.ernfiles in the playbook. - Computed values are read-only. Tasks cannot modify them.
task block
A task is a named group of shell commands. Tasks can depend on other tasks, run conditionally, and be scoped to a specific directory.commands is required.
Attributes
A human-readable description of what the task does.
The directory to run commands in. Overrides the playbook-level
working_dir from the errand block. Relative paths are resolved from the directory where errand was invoked.A boolean expression. When it evaluates to
false, the task is skipped. Tasks that depend on a skipped task are also skipped.An explicit list of tasks that must complete before this task runs. Write each as
task.<name>. Errand also infers dependencies from expression references in commands and condition.Shell commands to execute in order. Each command is a string expression and can use variables, computed values, and built-in functions. Commands stop at the first failure.
Examples
Task with dependencies, Errand runstest and lint before build:
Default task
When you callerrand run with no task name, Errand runs the task named default:
Notes
- Task names must be unique across all
.ernfiles in the playbook. - Commands run inside a built-in POSIX-compatible shell interpreter. No external shell is required, including on Windows.
- If a command fails, remaining commands in the same task are skipped and the task is marked as failed.
- Tasks that do not depend on a failed task continue to run normally.