Switch Switch

yaml
type: "io.kestra.plugin.core.flow.Switch"

Run tasks conditionally, i.e. decide which branch of tasks should be executed based on a given value.

This task runs a set of tasks based on a given value. The value is evaluated at runtime and compared to the list of cases. If the value matches a case, the corresponding tasks are executed. If the value does not match any case, the default tasks are executed.

Examples

yaml
id: switch
namespace: company.team

inputs:
  - id: string
    type: STRING
    required: true

tasks:
  - id: switch
    type: io.kestra.plugin.core.flows.Switch
    value: "{{ inputs.string }}"
    cases:
      FIRST:
        - id: first
          type: io.kestra.plugin.core.debug.Return
          format: "{{ task.id }} > {{ taskrun.startDate }}"
      SECOND:
        - id: second
          type: io.kestra.plugin.core.debug.Return
          format: "{{ task.id }} > {{ taskrun.startDate }}"
      THIRD:
        - id: third
          type: io.kestra.plugin.core.debug.Return
          format: "{{ task.id }} > {{ taskrun.startDate }}"
    defaults:
      - id: default
        type: io.kestra.plugin.core.debug.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 map of keys and a list of tasks to be executed if the conditional value matches the key.

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
  • Required:
  • Default: false

value

  • Type: string
  • Required:

Definitions

Was this page helpful?