Parameters and loops
Parameters
Section titled “Parameters”Parameters are inputs to the whole workflow. To add one, click empty canvas so no step is selected, then open Parameters in the right-hand panel.
Give it a name, a default and an optional description. Tick Required and the submitter has to supply a value.
Use it in any text field:
{{workflow.parameters.<name>}}Put {{workflow.parameters.image}} in a run-container’s Image field and you can
swap images without editing the step. Parameters compile to
spec.arguments.parameters, so any submitter can override them.
Open a step’s Run this once per item… section and pick one:
- Just once is the default. No loop.
- Once per item in a list takes a JSON list, a workflow parameter, or an
earlier step’s list output. Compiles to
withParam. - Once per item I type here takes one item per line. Compiles to
withItems. - Once per number in a range takes a count, or start and end, plus an optional
printf format such as
testuser%02d. Compiles towithSequence.
{{item}} is the current item. A run-container looping over
["dev", "staging", "prod"] with the argument --env {{item}} runs three times.
To fan out over data, have one step write a JSON list to its result, then pick
that output in the next step’s Once per item in a list.
Conditions
Section titled “Conditions”Put an expression in a step’s Only run this when… section. The step is skipped when it’s false, and always runs when it’s blank.
{{tasks.flip.outputs.result}} == headsThis runs only when flip returned heads. On a looping step the condition is
checked for each item.
Dagweave checks conditions as you type. See Expressions for what
you can refer to, {{=...}} expressions, and choosing which result of an earlier
step to wait for.