Stack Variables
Every field in the stack spec supports stack variables - special strings that are replaced with user-provided values when the stack is built. These variables can be used for highly dynamic workflows where specific or custom values are desired.
When combined with pipelines, it becomes possible to create highly customizable GitOps workflows for teams of any size and structure.
Variable Format
Stack variables follow this format:
{{variable}}
and supports the following characters:
a-z
0-9
-
Non-String Variables
When dealing with values that are not strings, such as numbers, objects, or arrays, the value can be escaped by appending a $
to the variable name.
For example:
{{$variable}}
When Cycle builds the stack, it strips out quotes around the variable string, and replaces it with the raw value of the variable.
Given
with the following values provided at build time:
Variable | Value |
---|---|
strvar | hello |
objvar | {"hello": "world"} |
the values would be replaced as such:
Default Variables
Default variable values can be set on a stack. In the absence of those variables when a build is triggered, the default variables will be used instead.
Interop with Pipeline Variables
Pipeline variables can be forwarded into a Create Stack Build step. This creates a powerful GitOps workflow, where things like version number or deployment tags based on ticket IDs can be forwarded from a CI system into a Cycle pipeline, and into a stack build. This fully automated system makes it easy to set up complex workflows, such as generating a deployment for every ticket in a task management system for testing bug fixes.
Setup Stack Variables
Learn how to set up stack variables using one of our interface-specific guides: