Set variables for each release (parameterised release)

I’d like to be able to add some “metadata” to each release.

The metadata remains the same irrespective of the environment.

The metadata does change on a release by release basis.

In the octopus “create-release” CLI, I can’t seem set any variables with “-v”.

I can set variables data when deploying a release (not creating a release(, but that would mean I have to store the release metadata outside of octopus and inject it during deployment…

Is there a way to store metadata for a release that I can reference inside scripts etc… ?

The metadata contains some specific URL’s to visit.

Hi @iamyohann

The create-release CLI command does indeed have a -v or --variable parameter for providing variable values.

However, as you noted the parameter won’t set variable values before the release is created. This is because the parameter currently only supports providing values for prompted variables used at deployment time.

We’ve discussed the idea internally of having prompted variables you can set at release creation time, but no decision has been made on implementing that feature and therefore I can’t guarantee if or when it might happen.

Really what you would need to do is to set a variable value before creating the release. This isn’t possible with the create-release command on it’s own, but you can update a variable value using the Octopus REST API. You can see an example of using the REST API from a PowerShell script in our API Examples in our docs:

Once you had updated your variables, you could then create the release.

Since the variable values are snapshotted at the time of the release being created, they would be stored for each deployment with the same value.

I hope that helps, but let me know if you have any questions!

Happy Deployments!

Hi Mark,

Thanks for your reply.

I’m not too sure if that solution could work at scale.

My concern is if multiple releases are being created in parallel as we kick off multiple builds at the same time, the the Octopus build variables could be inconsistent with the time when the release was created. We’d have to create a “lock” on the variables and manage that lock outside of octopus.

Is there an option to edit the variable that was snapshotted in the release via REST API?

I can see there’s some endpoints for refreshing snapshot etc… but I can’t seem to edit the variable snapshot directly… (I assume octopus is internally creating a copy of the project variables at that point in time?)


Hi @iamyohann

Agreed, at scale, you’d need to lock the variables outside of octopus when doing multiple releases in parallel which is not ideal.

In this instance, unfortunately, what you have described seeing is accurate. The /snapshot-variables API endpoint used to update variables in a release takes the latest of ALL variables, and it’s not currently possible to update an individual value.

It’s possible that in the future that may change, or the feature of having a release time variable would also help here.

The only other thing I can think to suggest and I’ll be upfront and admit this is a bit “hacky” is to consider prompted variables to provide the initial value on the first deployment. Then in subsequent deployments, what you could have is a script step that queries the Octopus REST API and looks to see if the variables already exist in a previous deployment’s variable manifest.

Consider the following prompted variable:

If you take a look at a deployment in the REST API, it has a variables Id:

You can then see if the variables have been provided:


You could then use that initial value in your deployment using an Output variable.

It’s not ideal, but might help you to bridge the gap in functionality until this is native to Octopus.

I hope that helps!

Best regards