If If

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

Process 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:
  - id: 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 if the condition is true.

condition

  • Type: string
  • Dynamic: βœ”οΈ
  • Required: ❌

The If condition which can be any expression that evaluates to a boolean value.

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

else

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

List of tasks to execute if the condition is false.

errors

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

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

Was this page helpful?