The foreach
directive in Keep workflows allows you to iterate over a list of items and perform actions for each item. This is particularly useful for processing multiple results returned by a step or performing actions on a collection of entities.
foreach
variable, allowing you to access its properties directly.foreach
to work sequentially on the same list of items.foreach
To use foreach
, include it as part of an action. The value of foreach
should be a reference to the list you want to iterate over.
foreach
In this example:
get-pods
step retrieves a list of Kubernetes pods.foreach
iterates over the results
returned by the get-pods
step.name
, namespace
, and status.
foreach
VariablesThe foreach
variable provides scoped access to the current item in the iteration.
In this case:
{{ foreach.value }}
refers to the current item in the list.metadata.name
, metadata.namespace
, and s
tatus.phase` dynamically.foreach
You can combine foreach
with if
conditions to filter or act selectively.
The foreach
directive in Keep workflows allows you to iterate over a list of items and perform actions for each item. This is particularly useful for processing multiple results returned by a step or performing actions on a collection of entities.
foreach
variable, allowing you to access its properties directly.foreach
to work sequentially on the same list of items.foreach
To use foreach
, include it as part of an action. The value of foreach
should be a reference to the list you want to iterate over.
foreach
In this example:
get-pods
step retrieves a list of Kubernetes pods.foreach
iterates over the results
returned by the get-pods
step.name
, namespace
, and status.
foreach
VariablesThe foreach
variable provides scoped access to the current item in the iteration.
In this case:
{{ foreach.value }}
refers to the current item in the list.metadata.name
, metadata.namespace
, and s
tatus.phase` dynamically.foreach
You can combine foreach
with if
conditions to filter or act selectively.