Skip to content

Commit e2c56ca

Browse files
Added example and clarifications
1 parent 2f367ef commit e2c56ca

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,27 @@ If you are using the [Structured configuration variables](/docs/projects/steps/c
163163
## Variable Recommendations
164164

165165
### Use standard characters in variable names
166-
Prefer using standard characters when naming variables. While it's technically possible to use almost any character, variables with non-standard characters can only be accessed in limited ways - such as via the `$OctopusParameters` dictionary. For broader compatibility, including support for Octostache expressions, stick to alphanumerics, periods (`.`), hyphens (`-`), underscores (`_`), and spaces. Octostache does not support characters outside this set, so following this convention ensures your variables function reliably across all usage contexts.
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.
167187

168188
### Group variables into Variable Sets
169189

0 commit comments

Comments
 (0)