Ir al contenido principal

Automation Variables

Actualizado hoy

Introducción

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. Click + Add variable.

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

  4. Click Guardar.

Automation Variables

Variables created here are available immediately in all actions and conditions in the automation.

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. Guardar the action.

Action Output Variable

ℹ️ NOTA: 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:

##{{MyVariable}}

In Condiciones de acción

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 PatchingEstado equals failed.

See Condiciones de acción for the full reference on condition types and operators.

Mapping to Script Variables

Script variables are named output slots defined in a script's Variables tab. The script writes a value to a script variable during execution, and the mapping in the Run Script action panel determines which automation variable stores that value — making it available to subsequent actions and conditions in the pipeline.

Script variables are for capturing output, not supplying input. To pass data into a script (device context, custom field values, system info), use system variables or custom fields via the {x} picker in the script editor.

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 capture.

  3. Open the Automation variables dropdown on that row.

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

When the script runs, the value it writes to that script variable is stored in the mapped automation variable and carried forward through the pipeline.

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

You can also set an automation variable inline from within a script. Use the inline ##{{variable=value}} syntax when your script produces other output you don't want polluting the variable (logs, status messages, etc.). Use Assign action output to variable when the script's only output is the value you want to capture.

Embed this anywhere in your script output:

##{{variable_name=value}}

Level's agent parses the script output for this pattern as the script runs. All other output passes through untouched. The variable must still be created in the script's Variables tab first.

💡 CONSEJO: 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.


Preguntas frecuentes

  • Where can I see all variables available in an automation? Open the automation and click Variables in the left sidebar. This lists all automation variables defined for that automation. System variables are always available too but don't appear here — see System Variables for the full list.

  • Can I use the same variable name in multiple automations? Yes. Variable names are scoped to the automation — PatchingEstado in one automation has nothing to do with PatchingEstado 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.

¿Ha quedado contestada tu pregunta?