# Variables

Variables are specific fields for tasks. They use the power of Pebble (opens new window) with Kestra's special context system, allowing powerful task composition.

Variables can use variable information registered/existing in the execution context. The context is data injected in Variables and can be from different sources:

# Default variables

# Flow & Execution

Flow & Execution variables allow using current context for this execution in order to customize the tasks (example: name file with current date or current execution id, ...)

The following table lists all the default variables available on each execution.

Parameter Description
{{ flow.id }} The name of the current flow ID
{{ flow.namespace }} The name of the current namespace
{{ flow.revision }} The revision of the current flow
{{ execution.id }} Return the execution Id, a unique id for each
{{ execution.startDate }} The start date of the current execution, it can be formatted with {{ dateFormat execution.startDate "yyyy-MM-dd HH:mm:ss.SSSSSS"}}
{{ task.id }} The current task ID
{{ task.type }} The current task Type (full class name)
{{ taskrun.id }} The current task ID
{{ taskrun.value }} The value for the current task run, only available with (Flowable Task)
{{ taskrun.attemptsCount }} The number of attempts for current task (when retry or restart is done)
{{ parents[].taskrun.value }} The value of parents task run, the index if based on closest Flowable Task, only available with tasks previsouly in a (Flowable Task)
{{ parents[].outputs }} The outputs of the parent task run, the index if based on closest Flowable Task, only available with tasks previously run in a (Flowable Task)
{{ parent.taskrun.value }} The value of closest (first) parent task run Flowable Task, only available with tasks run previously in a (Flowable Task)
{{ parent.outputs }} The outputs of (first) parent task run Flowable Task, only available with tasks previously run in a (Flowable Task)

If the flow is triggered by a schedule, these variables (vars) are also available :

Parameter Description
{{ schedule.date }} the date of current schedule
{{ schedule.next }} the date of next schedule
{{ schedule.previous }} the date of previous schedule

If the flow is triggered by a flow, these variables (vars) are also available:

Parameter Description
{{ trigger.executionId }} the execution id that triggers the current flow
{{ trigger.namespace }} the namespace of the flow that triggers the current flow
{{ trigger.flowId }} the flow id that triggers the current flow
{{ trigger.flowRevision }} the flow revision that triggers the current flow

Below is an example of typical usage:

id: context-example
namespace: io.kestra.tests

tasks:
  - id: echo
    type: io.kestra.core.tasks.debugs.Return
    format: |
      taskid: {{task.id}}
      date: {{  execution.startDate | date("yyyy-MM-dd HH:mm:ss.SSSSSS") }}

# Inputs variables

You can use any inputs using its name, example:

id: context-inputs
namespace: io.kestra.tests

inputs:
  - name: myinput
    type: STRING

tasks:
  - id: mytask
    type: io.kestra.core.tasks.debugs.Return
    format: "{{inputs.myinput}}"

# Outputs variables

Outputs variables can also be referencing their names with the form
outputs.NAME.PROPERTY :

  • NAME is the taskId you want to locate
  • PROPERTY is the property you want to use, each task type can emit different properties, so look at the
    documentation of one.
id: context-outpouts
namespace: io.kestra.tests

tasks:
    - id: task-id
      type: io.kestra.task.templates.Example
      format: "{{task.id}}"
    - id: flow-id
      type: io.kestra.task.templates.Example
      format: "{{outputs.task-id.child.value}}"

# More

In order to customize the :

Last Updated: 10/25/2022, 3:48:22 PM