...
For each entry in the data set, the foreach
command will execute all subsequent commands until a foreach.end
has been found.
By default the current iteration item can be accessed using ${vars.loop.item}
.
For example:
Code Block | ||
---|---|---|
| ||
vars:
people: ["Sam", "Sarah", "Carol"]
pipeline:
- foreach:
in: ${vars.people}
- log:
message: "Hello ${vars.loop.item}"
- foreach.end |
You can also define a loop item name using the as
parameter. In this case for reach iteration, the item is placed in the vars scope under the name specified by the as
parameter:
Code Block | ||
---|---|---|
| ||
vars: people: ["Sam", "Sarah", "Carol"] pipeline: - foreach: in: ${vars.people} as: person - log: message: "Hello ${vars.person}" - foreach.end |
...