Getting part of the Octopus.Release.Number into a project variable


I am trying to take the system variable #{Octopus.Release.Number} and pull out the major, minor, and revision number and put it into a project variable. We use everything from the release number, except the build number, to display on our diagnostics screen. I am already doing variable substitution on the web.config and want to pull in those parts of the release number. Is this possible? If so, how do I accomplish this?


Hi Kyle,

Thanks for reaching out. You can do so with a bit of Powershell magic, by grabbing the release version, splitting it into pieces and assigning each piece to an Octopus variable. To do so:

  1. Create a powershell step to get the version’s Major, Minor and Patch into Octopus variables using this snippet:
[system.version]$V = $OctopusParameters['Octopus.Release.Number']
Set-OctopusVariable -name "Major" -value $v.Major
Set-OctopusVariable -name "Minor" -value $v.Minor
Set-OctopusVariable -name "Patch" -value $v.Build
  1. Use the following variables on your other process steps to get the version values
$OctopusParameters["Octopus.Action[StepName].Output.Major"] #for major
$OctopusParameters["Octopus.Action[StepName].Output.Minor"] #for Minor
$OctopusParameters["Octopus.Action[StepName].Output.Patch"] #for Patch

Make sure to change the value StepName so it matches the name of the step set on (1). For more info about this technique check this blog post

Hope that helps!


Hi Dalmiro,

Sorry it has taken me so long to respond, but I just finished implementing this and it worked exactly as I would expect.

I will close the ticket. Thank you!!!