Switch
yaml
type: "io.kestra.core.tasks.flows.Switch"
Process some tasks conditionally depending on a contextual value
Allow some workflow based on context variables, for example branch a flow based on a previous task.
Examples
yaml
id: switch
namespace: io.kestra.tests
inputs:
- name: string
type: STRING
required: true
tasks:
- id: switch
type: io.kestra.core.tasks.flows.Switch
value: "{{inputs.string}}"
cases:
FIRST:
- id: 1st
type: io.kestra.core.tasks.debugs.Return
format: "{{task.id}} > {{taskrun.startDate}}"
SECOND:
- id: 2nd
type: io.kestra.core.tasks.debugs.Return
format: "{{task.id}} > {{taskrun.startDate}}"
THIRD:
- id: 3th
type: io.kestra.core.tasks.debugs.Return
format: "{{task.id}} > {{taskrun.startDate}}"
defaults:
- id: default
type: io.kestra.core.tasks.debugs.Return
format: "{{task.id}} > {{taskrun.startDate}}"
Properties
value
- Type: string
- Dynamic: ✔️
- Required: ✔️
- Min length:
1
The value to be evaluated
cases
- Type: object
- SubType: array
- Dynamic: ❌
- Required: ❌
The case switch, as map with key the value, value the list of tasks
defaults
- Type: array
- SubType: Task
- Dynamic: ❌
- Required: ❌
errors
- Type: array
- SubType: Task
- Dynamic: ❌
- Required: ❌
List of tasks to run if any tasks failed on this FlowableTask
Outputs
defaults
- Type: boolean
- Default:
false
value
- Type: string