Expressions¶
Overview¶
Instead of hard-coding every value, a protocol.yml can use expressions to programmatically control the workflow at run time. Expressions are written by enclosing them in $( ... ), and within an expression a small set of contexts and functions are available. These can be combined freely within a single expression.
Contexts¶
workflow¶
Data about the current workflow run.
Value |
Contents |
|---|---|
|
ID of the current workflow |
|
Pointer to the file that triggered the workflow |
|
ISO 8601 datetime string of when the workflow started |
|
ID of the pipeline that triggered this workflow |
config¶
Data configured by the pipeline’s user, keyed by the config IDs declared under config in protocol.yml (see protocol.yml field reference). Given:
config:
foo:
label: Foo
type: string
bar:
label: Hey Bear
type: object
$( config.foo ) and $( config.bar ) are valid; $( config.baz ) errors, because baz was never declared.
constants¶
All constant values defined under constants in protocol.yml. If a constant contains an expression, it’s evaluated before access. Given:
constants:
foo: "bar"
baz:
- 1
- 2
$( constants.foo ) and $( constants.baz ) are valid; $( constants.qux ) errors.
protocol¶
Reads back the manifest-mirror fields declared at the top level of protocol.yml (see the manifest fields table in protocol.yml field reference) — for example $( protocol.name ) or $( protocol.version ). Returns null if the field wasn’t specified.
steps¶
Contains every step’s result. A step is only readable in this context once it has run or been skipped. A step can be addressed by its id or by its list index:
steps[0]steps['stepOne']steps.stepOne
Prefer the named-ID form over the numeric-index form. The compiler itself warns Using a number to access a step instead of an id is prone to error and not recommended — the expression still compiles, but give every step an id and address it by name. Use the bracket form (steps["some-step-id"]) when the ID contains a hyphen.
Value |
Contents |
|---|---|
|
Whatever the task-script function returned |
|
Only populated when that step set |
|
One of |
|
|
|
|
|
|
Functions¶
A deliberately small list — anything beyond this belongs in a task script, not the protocol. There is no foreach, parallel, or loop construct in v3.
Function |
Description |
Example |
|---|---|---|
|
First value that isn’t |
|
|
Negates the value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See also
For the fields these expressions read from and write to — config, constants, steps, successWhen, onFailed — see protocol.yml field reference.