Skip to content

Commit 98e3a31

Browse files
Clarification of supported characters in variable names (#2737)
1 parent 4e419c2 commit 98e3a31

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/pages/docs/projects/variables/getting-started.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,29 @@ If you are using the [Structured configuration variables](/docs/projects/steps/c
162162

163163
## Variable Recommendations
164164

165+
### Use standard characters in variable names
166+
Prefer using standard characters when naming variables. While it's technically possible to include almost any character, **variable names** with non-standard characters can only be accessed in limited ways - such as via the `$OctopusParameters` dictionary. Variable values can include any character.
167+
168+
| Variable name | Value |
169+
| ---------------| -------------------------------------- |
170+
| `WontWork` | `#{Octopus.Action[StepA].Output.Foo!}` |
171+
| `Works` | `#{Octopus.Action[StepA].Output.Ba-r}` |
172+
173+
**Step A**
174+
```ps
175+
Set-OctopusVariable -name "Foo!" -value "FooValue"
176+
Set-OctopusVariable -name "Ba-r" -value "BarValue"
177+
```
178+
179+
**Step B**
180+
```ps
181+
$OctopusParameters["Works"] # Returns: BarValue
182+
$OctopusParameters["WontWork"] # Returns: #{Octopus.Action[StepA].Output.Foo!}, not FooValue
183+
$OctopusParameters["Octopus.Action[StepA].Output.Foo!"] # Returns: FooValue
184+
```
185+
186+
To ensure your variable can be accessed via Octostache expressions, stick to alphanumerics, periods (`.`), hyphens (`-`), underscores (`_`), and spaces for the **name** of the variable.
187+
165188
### Group variables into Variable Sets
166189

167190
Variables sometimes naturally fit into groups, and often you'll find multiple applications will use these groups. Octopus has [Variable Sets](/docs/projects/variables/library-variable-sets); allowing you to group variables into a reusable set so that they can be used by other projects.

0 commit comments

Comments
 (0)