The image shows an isometric illustration of a central octopus-like icon connected to multiple brain icons in a hub-and-spoke network pattern against a purple-to-blue gradient background.

Octopus Easy Mode - Variables

Matthew Casperson
Matthew Casperson

In the previous post, you created a simple “Hello, World!” script project. In this post, you’ll add environment-scoped variables to customize the message displayed in each environment.

Prerequisites

  • An Octopus Cloud account. If you don’t have one, you can sign up for a free trial.
  • The Octopus AI Assistant Chrome extension. You can install it from the Chrome Web Store.

The Octopus AI Assistant will work with an on-premises Octopus instance, but it requires more configuration. The cloud-hosted version of Octopus doesn’t need extra configuration. This means the cloud-hosted version is the easiest way to get started.

Creating the project

Paste the following prompt into the Octopus AI Assistant and run it:

Create a Script project called "02. Script App with Environment Vars", and then:
* Add three project variables called "Message", each scoped to an environment, with the following values:
  * Development: "Hello from Development!"
  * Test: "Hello from Testing!"
  * Production: "Hello from Production!"
* Update the script step to echo the "Message" variable using the syntax "#{Message}"

As before, the Octopus AI Assistant will prompt you to approve the changes before applying them to your Octopus instance.

You can now create a release and deploy it through the environments. The script step prints the value of the Message variable scoped to each environment.

What just happened?

You created a sample project with:

  • Three project variables called Message, each scoped to an environment, and a different message that will be displayed when the deployment runs.
  • A script step that echoes the value of the Message variable using variable substitutions.

What’s next?

The next step is to add a manual approval step before deploying to production.

Matthew Casperson

Related posts