Workflow engine variables
Workflow engine variables are expressions that enable you to pass data between Steps while editing a Workflow. You may wish to use previous Steps’ outputs or statuses in other Steps of your Workflow. This could be to perform different operations on given results, such as arithmetic, logical, comparison operations, etc. Expression language also enables you to use your Workflow’s input parameters as step inputs.
The easiest way to create these expressions is by using the variable picker. Whether an expression was written manually or selected using the variable picker, it will be saved as part of the Workflow YAML using the syntax described below.
Workflow Inputs
To reference Workflow input, use the following syntax:
{{ inputs.param_name }}
Event payload
To reference data in an event that triggered an Event-Based Workflows, use the following syntax:
{{ event.payload }} # full event payload
{{ event.payload.issue.user }} # fetch the value of user attribute in event payload that can look like this: { "issue": {"user": "me" }}
Step output
To reference step’s output, use the following syntax:
{{ steps.S1.output }}
💡 S1 refers to the step’s ID. You may also use last instead of the step ID to get the output of the last executed step.
JSON dot walking
The expression language supports JSON dot walking, which enables you to copy specific key-value pairs from a JSON object output and use the specific key-value pair in subsequent steps of your Workflow. For example:
Step Status
To use a previous step’s output, use the following syntax:
{{ steps.S1.status }}
Workflow Variables
To use Workflow's variables, use the following syntax:
{{ variables.variable_name }}
Metadata Variables
The following metadata variables get populated for each Workflow:
{{ metadata.automation_name }}
{{ metadata.automation_url }}
{{ metadata.automation_id }}
{{ metadata.workspace_id }}
{{ metadata.pack_id }}
{{ metadata.execution_id }}
{{ metadata.execution_url }}
{{ metadata.start_time }}
{{ metadata.user_email }}
{{ metadata.user_groups }}
Python syntax
In python steps variables, steps and inputs are exposed using the context
variable. Thus, all the above expressions can be accessed using the following expressions in python:
context.inputs.param_name
context.steps.S1.output
context.steps.S1.output.user.id
context.steps.last.output
context.steps.S1.status
context.event.payload
context.event.payload.issue.user
context.metadata.automation_name
In python, variables can be set like this:
context.variables.variable_name = value // setting variables