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
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
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
Variablesforeach
variable provides scoped access to the current item in the iteration.
{{ foreach.value }}
refers to the current item in the list.metadata.name
, metadata.namespace
, and s
tatus.phase` dynamically.foreach
foreach
with if
conditions to filter or act selectively.