If If

yaml
type: "io.kestra.core.tasks.flows.If"

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: if
namespace: io.kestra.tests

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

tasks:
  - id: if
    type: io.kestra.core.tasks.flows.If
    condition: "{{inputs.string == 'Condition'}}"
    then:
      - id: when-true
        type: io.kestra.core.tasks.log.Log
        message: 'Condition was true'
    else:
      - id: when-false
        type: io.kestra.core.tasks.log.Log
        message: 'Condition was false'

Properties

then

  • Type: array
  • SubType: Task
  • Dynamic:
  • Required: ✔️
  • Min items: 1

List of tasks to execute when the condition is true.

condition

  • Type: string
  • Dynamic: ✔️
  • Required:

If condition, must coerce to a boolean.

Boolean coercion allows 0, -0, null and '' to coerce to false, all other values to coerce to true.

else

  • Type: array
  • SubType: Task
  • Dynamic:
  • Required:

List of tasks to execute when the condition is false.

errors

  • Type: array
  • SubType: Task
  • Dynamic:
  • Required:

List of tasks to execute in case of errors on a child task.

Definitions