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?
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:
Create a powershell step to get the version’s Major, Minor and Patch into Octopus variables using this snippet:
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