Solution Variables
Variables allow solutions to have environment-specific configuration without modifying the underlying actions or sequences.
What Are Variables?
Section titled “What Are Variables?”Variables are placeholders in your solution that can have different values per environment:
| Variable | Development | Staging | Production |
|---|---|---|---|
database_host | dev-db.local | staging-db.company.com | prod-db.company.com |
log_level | debug | info | warn |
replica_count | 1 | 2 | 5 |
Variable Templates
Section titled “Variable Templates”Variables are defined as templates on the solution, then values are set per environment.
Template Properties
Section titled “Template Properties”| Property | Description | Required |
|---|---|---|
| Name | Identifier (e.g., database_host) | Yes |
| Label | Display name | Yes |
| Help Text | Guidance for operators | No |
| Control Type | Input type (text, select, etc.) | Yes |
| Default Value | Fallback if not set | No |
| Required | Must have a value | Yes |
Control Types
Section titled “Control Types”Single-line text input:
┌─────────────────────────────────────────────────────────┐│ Database Hostname ││ ┌───────────────────────────────────────────────────┐ ││ │ db.example.com │ ││ └───────────────────────────────────────────────────┘ ││ Enter the primary database server address │└─────────────────────────────────────────────────────────┘Use for: Hostnames, URLs, paths, simple values
Multiline
Section titled “Multiline”Multi-line text area:
┌─────────────────────────────────────────────────────────┐│ Configuration JSON ││ ┌───────────────────────────────────────────────────┐ ││ │ { │ ││ │ "feature_flags": { │ ││ │ "new_checkout": true │ ││ │ } │ ││ │ } │ ││ └───────────────────────────────────────────────────┘ ││ JSON configuration for the application │└─────────────────────────────────────────────────────────┘Use for: JSON, YAML, configuration files, scripts
Select
Section titled “Select”Dropdown selection:
┌─────────────────────────────────────────────────────────┐│ Log Level ││ ┌───────────────────────────────────────────────────┐ ││ │ info ▼ │ ││ └───────────────────────────────────────────────────┘ ││ • debug ││ • info ││ • warn ││ • error │└─────────────────────────────────────────────────────────┘Use for: Predefined options, log levels, regions
Checkbox
Section titled “Checkbox”Boolean toggle:
┌─────────────────────────────────────────────────────────┐│ Enable Debug Mode ││ ┌───┐ ││ │ ✓ │ Enable ││ └───┘ ││ Turn on detailed logging for troubleshooting │└─────────────────────────────────────────────────────────┘Use for: Feature flags, on/off settings
Sensitive
Section titled “Sensitive”Masked input for secrets:
┌─────────────────────────────────────────────────────────┐│ API Key ││ ┌───────────────────────────────────────────────────┐ ││ │ •••••••••••••••••••••••••• │ ││ └───────────────────────────────────────────────────┘ ││ API key for external service integration │└─────────────────────────────────────────────────────────┘Use for: Passwords, API keys, tokens, secrets
Creating Variable Templates
Section titled “Creating Variable Templates”In the Solution Editor
Section titled “In the Solution Editor”- Open solution detail page
- Navigate to Variables tab
- Click Add Variable Template
- Configure template properties
- Save
┌─────────────────────────────────────────────────────────┐│ Add Variable Template │├─────────────────────────────────────────────────────────┤│ ││ Name: [database_host ] ││ Label: [Database Hostname ] ││ Help Text: [Primary PostgreSQL server ] ││ ││ Control Type: [Text ▼] ││ ││ Default: [localhost ] ││ Required: [✓] ││ ││ [Cancel] [Add] │└─────────────────────────────────────────────────────────┘Setting Environment Values
Section titled “Setting Environment Values”Per-Environment Configuration
Section titled “Per-Environment Configuration”- Navigate to the environment detail page
- Find the solution in the list
- Click Configure Variables
- Enter values for each variable
- Save
┌─────────────────────────────────────────────────────────┐│ Configure Variables: customer-portal ││ Environment: Production │├─────────────────────────────────────────────────────────┤│ ││ Database Hostname ││ ┌───────────────────────────────────────────────────┐ ││ │ prod-db.company.com │ ││ └───────────────────────────────────────────────────┘ ││ ││ Log Level ││ ┌───────────────────────────────────────────────────┐ ││ │ warn ▼ │ ││ └───────────────────────────────────────────────────┘ ││ ││ Replica Count ││ ┌───────────────────────────────────────────────────┐ ││ │ 5 │ ││ └───────────────────────────────────────────────────┘ ││ ││ [Cancel] [Save] │└─────────────────────────────────────────────────────────┘Using Variables in Actions
Section titled “Using Variables in Actions”Resolved variables reach an action in two ways during deployment:
{{...}}substitution in command arguments, the script file name, and the working directory. The supported placeholder syntaxes are{{variable}}(mustache) and${variable}(shell-style).MANTIS_*environment variables injected into the executed process. Each resolved variable is exposed as an uppercased,MANTIS_-prefixed environment variable (for example,database_hostbecomesMANTIS_DATABASE_HOST).
In Command Payloads
Section titled “In Command Payloads”Command payloads are structured (a binary plus ordered arguments), so reference
variables inside individual arguments with {{...}}:
- Binary:
docker - Argument 1:
run - Argument 2:
--env - Argument 3:
DB_HOST={{database_host}} - Argument 4:
--env - Argument 5:
LOG_LEVEL={{log_level}} - Argument 6:
myapp
When using the DefaultShell executor (the default), arguments are passed
directly to the binary without any shell interpretation, so shell metacharacters
are treated as literal values. When using the Sh, Bash, Pwsh, or Zsh
executors, Mantis rejects shell metacharacters (;, |, $, `, etc.)
in arguments before execution, preventing chaining, piping, or $VAR expansion;
the arguments are then safely quoted and passed to the shell as a single
composed command.
In Script Payloads
Section titled “In Script Payloads”A script’s content is not substituted. Read resolved variables from their
MANTIS_* environment variables instead:
#!/bin/bashecho "Connecting to $MANTIS_DATABASE_HOST"docker compose up -d --scale web="$MANTIS_REPLICA_COUNT"Variable Resolution
Section titled “Variable Resolution”During deployment, Mantis resolves variables through five precedence levels. Later levels override earlier ones:
Variable Inheritance
Section titled “Variable Inheritance”Solution Level
Section titled “Solution Level”Default values defined on the solution template (precedence level 1).
Tenant Common Level
Section titled “Tenant Common Level”Tenant-wide variables that apply across all projects. A value set without an environment applies to every environment (level 2); a value scoped to a specific environment overrides that for that environment only (level 3).
Tenant Project Level
Section titled “Tenant Project Level”Variables tied to this specific project within the tenant. An unscoped value applies to all environments (level 4); an environment-scoped value provides the final, highest-priority override (level 5).
Best Practices
Section titled “Best Practices”1. Use Descriptive Names
Section titled “1. Use Descriptive Names”Good: database_primary_host, api_gateway_urlBad: db, host1, var12. Add Help Text
Section titled “2. Add Help Text”Help operators understand what values to provide:
Variable: connection_stringHelp: PostgreSQL connection string in format: postgres://user:pass@host:5432/dbname3. Set Sensible Defaults
Section titled “3. Set Sensible Defaults”Provide defaults for development/testing:
Variable: log_levelDefault: info(Production can override to "warn")4. Mark Secrets as Sensitive
Section titled “4. Mark Secrets as Sensitive”Always use the sensitive control type for:
- Passwords
- API keys
- Tokens
- Certificates
- Connection strings with credentials
5. Validate Early
Section titled “5. Validate Early”Set variables as required when they must have values:
Variable: database_hostRequired: true(Deployment fails if not set)Common Variable Patterns
Section titled “Common Variable Patterns”Database Configuration
Section titled “Database Configuration”| Variable | Type | Example |
|---|---|---|
database_host | Text | db.example.com |
database_port | Text | 5432 |
database_name | Text | myapp_production |
database_user | Text | app_user |
database_password | Sensitive | ••••••• |
Feature Flags
Section titled “Feature Flags”| Variable | Type | Example |
|---|---|---|
feature_new_ui | Checkbox | true |
feature_beta_api | Checkbox | false |
feature_analytics | Checkbox | true |
Scaling
Section titled “Scaling”| Variable | Type | Example |
|---|---|---|
web_replicas | Text | 3 |
worker_replicas | Text | 2 |
max_connections | Text | 100 |
Troubleshooting
Section titled “Troubleshooting”Variable Not Substituted
Section titled “Variable Not Substituted”Symptom: Seeing {{variable_name}} in output
Solutions:
- Check variable is defined on solution
- Check environment has a value set
- Verify spelling matches exactly
- Remember that script content is never substituted — a script should read
the value from its
MANTIS_*environment variable instead
Deployment Fails: Missing Required Variable
Section titled “Deployment Fails: Missing Required Variable”Symptom: Deployment fails with “required variable not set”
Solution: Set the value on the target environment before deploying
Sensitive Value Exposed in Logs
Section titled “Sensitive Value Exposed in Logs”Symptom: Secret appears in deployment logs
Solution: Ensure variable is marked as sensitive control type
Next Steps
Section titled “Next Steps”- Creating Solutions - Create new solutions
- Versioning - Version management
- Promotion Lifecycle - Environment progression
- Overview - Return to solutions overview
