Skip to main content

Automation Variables

Per-automation variables for storing and passing data between automation steps, scripts, and action conditions.

Introduction

Automation variables let actions pass data to each other within the same pipeline. An action writes a value to a variable — a script's exit code, a custom field value, a patching result — and a later action or condition reads it.

Variables are scoped to the automation they're defined in. They don't carry over between automations.


Creating Automation Variables

There are two ways to create an automation variable.

From the Variables Tab

  1. Open an automation and click Variables in the left sidebar.

  2. Select the Custom tab.

  3. Click + Add variable.

  4. Enter a name (no spaces) and an optional default value.

  5. Click Save.

Automation Variables view with Custom and System tabs

Variables created on the Custom tab are available immediately in all actions and conditions in the automation.

Select the System tab to search the read-only reference of built-in Level variables. It shows each variable's reference, description, type, and an example value. System variables are always available and do not need to be created. See System Variables for details.

From an Action's Output

Any action can write its output to a variable at run time.

  1. Open an action in edit mode and scroll to Additional options.

  2. In the Assign action output to variable field, enter a variable name or select an existing one.

  3. Save the action.

Action Output Variable

ℹ️ NOTE: This is the same mechanism shown by the orange (x) badge on pipeline cards. If you see an (x) badge on an action, that action is reading from or writing to a variable.


Using Variables

In Actions and Scripts

Anywhere variable rendering is supported, click the variable icon to insert a variable by name. You can also type the reference directly using double-curly-brace syntax, such as {{MyVariable}}.

In Action Conditions

Variables can be read in action conditions to control whether a step runs. For example: only fire a Create Alert action if a variable named PatchingStatus equals failed.

See Action Conditions for the full reference on condition types and operators.

Mapping to Script Variables

Script variables are named values defined in a script's Variables tab. In a Run Script action, mapping a script variable to an automation variable lets values flow in both directions:

  • Before the script runs, Level renders the automation variable's current value into the mapped script variable. This lets a reusable saved script receive automation input without hardcoding an automation-specific variable name in the script.

  • If the script assigns a new value to the mapped script variable, Level writes that value back to the automation variable so later actions and conditions can use it.

To map a script variable to an automation variable:

  1. Open the Run Script action in edit mode.

  2. In the Script variables section, find the script variable you want to map.

  3. Open the Automation variables dropdown on that row.

  4. Select an existing automation variable or click Create new variable.

When the script starts, the mapped script variable receives the automation variable's current value. To send a new value back to the automation, assign the script variable using {{script_variable_name=value_expression}}.

Level replaces that assignment with the correct command for the script's shell. The script variable must exist in the script's Variables tab and be mapped in the Run Script action.

ℹ️ NOTE: The Script variables section only appears when the selected script has at least one variable defined in its Variables tab.

Use Assign action output to variable instead when the script's entire standard output is the value you want to capture.

💡 TIP: This pattern — capture output → check it in a condition — is the standard way to build conditional failure handling in Level. See Building Automations for a full walkthrough using this pattern.


FAQ

  • Where can I see all variables available in an automation? Open the automation and click Variables in the left sidebar. The Custom tab lists variables defined for that automation. The System tab contains a searchable, read-only reference of built-in variables. See System Variables for details.

  • Can I use the same variable name in multiple automations? Yes. Variable names are scoped to the automation — PatchingStatus in one automation has nothing to do with PatchingStatus in another.

  • What value does a variable have before any action writes to it? It uses the default value set when the variable was created. If no default was set, it's empty.

  • Can I read a variable from a previous automation run? No. Variables reset at the start of each run. They don't persist between runs.

Did this answer your question?