Variable
The variable system supports three different types of variables, each with different scoping and synchronization behavior.
Template Variables (Var Block)
Template variables are synced across all collaborators in real-time. These are the primary variable type for shared runbook state.
- Synchronization: Changes are immediately visible to all collaborators
- Persistence: Stored with the runbook document
- Scope: Available throughout the entire runbook
- Use case: Shared configuration, user inputs, persistent state
Variables can be set with a name and value. The value field supports full templating syntax, allowing you to build variables from other variables or block outputs.
Local Variables (Local Var Block)
Local variables are not synced and remain private to each user's session.
- Synchronization: Private to individual users, not shared
- Persistence: Lost when the session ends
- Scope: Available throughout the runbook for that user only
- Use case: User-specific settings, temporary calculations, private credentials
Setting Variables from Script and Terminal Blocks
Script and Terminal blocks can set multiple template variables by writing to the $ATUIN_OUTPUT_VARS file. This provides a programmatic way to create variables based on command execution.
Usage:
# Simple format for single-line values
echo "name=value" >> $ATUIN_OUTPUT_VARS
# Heredoc format for multiline values
echo "description<<EOF" >> $ATUIN_OUTPUT_VARS
echo "Line 1 of description" >> $ATUIN_OUTPUT_VARS
echo "Line 2 of description" >> $ATUIN_OUTPUT_VARS
echo "EOF" >> $ATUIN_OUTPUT_VARS
# For longer multiline strings, use a command group for efficiency
{
echo "myvar<<EOF"
echo "Some"
echo "Multiline"
echo "String"
echo "EOF"
} >> $ATUIN_OUTPUT_VARS
- Format: Two formats supported:
- Simple:
KEY=VALUEentries, one per line - Heredoc:
KEY<<DELIMITERfollowed by content lines untilDELIMITER(for multiline values) - Timing: Variables are captured when scripts exit successfully or terminals close
- Location: Works with both local and remote (SSH) execution
See the Script and Terminal documentation for detailed examples.
Variable Display
Use the Variable Display block to view all currently set variables and their values. This shows both template (synced) and local (not synced) variables for debugging and state inspection.
For variables containing markdown content, use the Markdown Render block to display beautifully formatted output with collapse/expand and fullscreen capabilities.
Usage
Both variable types can be referenced using the same template syntax:
Template Integration
All variable blocks integrate with the templating system, enabling complex variable manipulation and conditional logic.