Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: src/layouts/Default.astro
pubDate: 2023-01-01
modDate: 2023-01-01
modDate: 2026-06-12
title: Substitute variables in templates
description: Package steps have a feature that allows you to replace variables in any file.
navOrder: 80
Expand All @@ -16,13 +16,13 @@

The following example shows you how to use the Substitute Variables in Templates feature to provide a different login form to the different environments you're deploying to. In this example, we're deploying to a **Test** and **Production** environment.

1. Create the login variable in Octopus. From the: [project](/docs/projects) overview page, click **Variables**.

Check failure on line 19 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:19 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "1. Create the login variable i..."] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md032.md

Check failure on line 19 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:19 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "1. Create the login variable i..."] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md032.md
- Enter a the name for the variable, for instance, *LoginURL*.

Check failure on line 20 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:20 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- Enter a the name for the var..."] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md032.md

Check failure on line 20 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:20:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md

Check failure on line 20 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:20 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- Enter a the name for the var..."] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md032.md

Check failure on line 20 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:20:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md
- Enter the first value for the variable, for instance, *https://test.example.com/login*.

Check failure on line 21 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Bare URL used

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:21:60 MD034/no-bare-urls Bare URL used [Context: "https://test.example.com/login"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md034.md

Check failure on line 21 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:21:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md

Check failure on line 21 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Bare URL used

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:21:60 MD034/no-bare-urls Bare URL used [Context: "https://test.example.com/login"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md034.md

Check failure on line 21 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:21:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md
- Scope this value to the test environment by clicking the *Define Scope* field and selecting the test environment.

Check failure on line 22 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:22:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md

Check failure on line 22 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:22:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md
- Click **ADD ANOTHER VALUE**.

Check failure on line 23 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:23:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md

Check failure on line 23 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:23:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md
- Enter the second value for the variable, for instance, *https://example.com/login*.

Check failure on line 24 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Bare URL used

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:24:61 MD034/no-bare-urls Bare URL used [Context: "https://example.com/login"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md034.md

Check failure on line 24 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:24:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md

Check failure on line 24 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Bare URL used

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:24:61 MD034/no-bare-urls Bare URL used [Context: "https://example.com/login"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md034.md

Check failure on line 24 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:24:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md
- Scope this value to the production environment by clicking the *Define Scope* field and selecting the production environment, and click **SAVE**. In this example, you now have the following variables:

Check failure on line 25 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:25:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md

Check failure on line 25 in src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

src/pages/docs/projects/steps/configuration-features/substitute-variables-in-templates.md:25:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md007.md

| Variable Name | Value | Scope |
| ----------------------- | --------------- | -------- |
Expand Down Expand Up @@ -74,7 +74,7 @@
:::

:::div{.warning}
By default, **warnings** will be treated as **errors** when replacing variables in files using this feature. To override this behavior, set the variable **Octopus.Action.Package.IgnoreVariableReplacementErrors** to **True** in your project. By doing this, warnings will be treated as such and the deployment will not be marked as failed.
By default, when variable substitution fails, the deployment will **not** fail. This variable substitution error will be logged at the **Verbose** level. To fail the step when substitution fails, set the variable **OctopusShouldFailDeploymentOnSubstitutionFails** to **True** in your project.
:::

## Examples {#SubstituteVariablesInFiles-SomeExamples}
Expand Down
Loading