EachSequential
EachSequential
type: "io.kestra.core.tasks.flows.EachSequential"
For each value in the list, execute one or more tasks sequentially.
The list of tasks
will be executed for each item sequentially. The value must be a valid JSON string representing an array, e.g. a list of strings ["value1", "value2"]
or a list of dictionaries [{"key": "value1"}, {"key": "value2"}]
.
You can access the current iteration value using the variable . The task list will be executed sequentially for each item.
We highly recommend triggering a subflow for each value. This allows much better scalability and modularity. Check the flow best practices documentation and the following Blueprint for more details.
Examples
The taskrun.value from the
each_sequential
task is available only to immediate child tasks such as thebefore_if
and theif
tasks. To access the taskrun value in child tasks of theif
task (such as in theafter_if
task), you need to use the syntaxas this allows you to access the taskrun value of the parent task
each_sequential
.
id: loop_example
namespace: dev
tasks:
- id: each_sequential
type: io.kestra.core.tasks.flows.EachSequential
value: ["value 1", "value 2", "value 3"]
tasks:
- id: before_if
type: io.kestra.core.tasks.debugs.Return
format: 'Before if {{ taskrun.value }}'
- id: if
type: io.kestra.core.tasks.flows.If
condition: '{{ taskrun.value == "value 2" }}'
then:
- id: after_if
type: io.kestra.core.tasks.debugs.Return
format: 'After if {{ parent.taskrun.value }}'
This task shows that the value can be a bullet-style list. The task iterates over the list of values and executes the
each-value
child task for each value.
id: each_sequential
namespace: dev
tasks:
- id: each-sequential
type: io.kestra.core.tasks.flows.EachSequential
value:
- value 1
- value 2
- value 3
tasks:
- id: each-value
type: io.kestra.core.tasks.debugs.Return
format: "{{ task.id }} with value '{{ taskrun.value }}'"
Properties
tasks
- Type: array
- SubType: io.kestra.core.models.tasks.Task
- Dynamic: ❌
- Required: ✔️
- Min items:
1
value
- Type:
- string
- array
- Dynamic: ✔️
- Required: ✔️
The list of values for this task. The value car be passed as a string, a list of strings, or a list of objects.
errors
- Type: array
- SubType: io.kestra.core.models.tasks.Task
- Dynamic: ❌
- Required: ❌
List of tasks to run if any tasks failed on this FlowableTask.