Octopus Deploy Documentation

Define and use variables

Last updated

Octopus allows you to define variables and scope them for use in different phases of your deployments. Variables allow you to have a consistent deployment process across your infrastructure without having to hard-code or manually update configuration settings that differ across environments, deployment targets, channels, or tenants.

  1. From the Hello world project you created earlier, click Variables in the left menu.
  2. Enter Helloworld.Greeting into the variable name column on the first row of the table.
  3. Add Hello, Development into the value column.
  4. Click the Scope column and select the Development environment.
  5. Click ADD ANOTHER VALUE button.
  6. Add Hello, Test and scope it to the Test environment.
  7. Click ADD ANOTHER VALUE button.
  8. Add Hello, Production and scope it to the Production environment.
  9. Click the SAVE button.

The hello world variables

Steps in the deployment process can reference the variables.

  1. Click Process on the left menu.
  2. Select the Hello World step.
  3. Change the script in the script step based on your language of choice:
Write-Host $OctopusParameters["Helloworld.Greeting"]
greeting=$(get_octopusvariable "Helloworld.Greeting")
echo $greeting

If you are using Octopus Cloud, Bash scripts require you to select the Hosted Ubuntu worker pool. The Default Worker Pool is running Windows and doesn't have Bash installed.

  1. Click the SAVE button and create a new release.

A release snapshots everything about your project, including variables and the deployment process. You have to create a new release to see any changes.

As you promote through the environments, you will see the greeting change.

The results of the hello world deployment with variables

The next step will add an approval process using manual interventions.

Further Reading

For further reading on variables in Octopus Deploy please see:

Previous     Next

Need support? We're here to help.