OctopusRelease variable for Redeployments

While using variable #{Octopus.Release.Number} to get the release number directly, but sometimes we are redeploying same build at that time additionally its generating like _1,_2 at the end of #{Octopus.Release.Number}.

How will get this type information using OctopusRelease variable when redeploying same build ?

Like example below mentioned

1st deployment = #{Octopus.Release.Number} = 20.11.2020-Semversion-tag
when Redeploying getting release number like = 20.11.2020-Semversion-tag_1

Thanks in Advance!

Hi @maruboyinarao,

Thank you for contacting Octopus Support.

If your packages line up with your builds, you could possibly use #{Octopus.Package.Version}.

Let me know if this alternative may work for you. If not, we can dive deeper.


Hi @maruboyinarao,

I’d like to jump in on this one quickly as I believe you may be referring to the installation directory of the package which is appending the _1 to that directory on the redeployment. Is that accurate? If so, the closes to get this is the system variable Octopus.Action[_name_].Output.Package.InstallationDirectoryPath to grab this directory the package was installed to (which will look something like C:\Octopus\Tentacle\Apps\Production\MyApp\20.11.2020-Semversion-tag_1 during the redeployment). Hopefully that helps?

Let me know how you go or if we’ve misunderstood anything about what you’re after. :slight_smile:

Best regards,


Hi @Kenneth_Bates

Thanks for your Response!

Initially to garbing the deployment directory path info we are using “Octopus.Action[name].Output.Package.InstallationDirectoryPath” variable

After that we required to removing additional information from the directory path “C:\Octopus\Tentacle\Apps\Production\MyApp\20.11.2020-Semversion-tag” using #{Octopus.Release.Number} variable.

For the first time deployment octopus variable #{Octopus.Release.Number} is working fine. When we traying to redeploying same build the #{Octopus.Release.Number} is not working.

first time deployment : #{Octopus.Release.Number} = 20.11.2020-Semversion-tag [Working fine]

Redeployment : #{Octopus.Release.Number} = 20.11.2020-Semversion-tag_1 [Not working]

Kindly suggest on this.

Hi @maruboyinarao,

Thanks for following up! If I’m understanding your scenario correctly (please let me know if I’m mistaken in any way), your releases are versioned in a way to match an included package’s version. e.g. a package being deployed is versioned 2020.11.2020-Semversion-tag as in your example, and that’s what’s setting the version of the release you’re creating, so these will always match.

When Octopus deploys a package and extracts the contents it creates the folder structure as C:\Octopus\Tentacle\Applications\[Environment]\[PackageId]\[PackageVersion]. When you redeploy the same version of the package Octopus creates a new folder appending _1 (then _2, and so on) to the [PackageVersion] folder so as not to overwrite the previous installation.

Since I believe your releases are versioned to match an included package’s version, this folder would then match on the first deploy, but then not on the next because of the _1 appended to the end of the folder since it doesn’t match the release version being deployed.

The variable Octopus.Action[PackageStepName].Output.Package.InstallationDirectoryPath will give you the full path (including the _1 at the end in the case of a redeployment). But you’d need to trim just this part off the path, and the easiest way would be to use the following PS:

$folder = $OctopusParameters['Octopus.Action[PackageStepName].Output.Package.InstallationDirectoryPath'].Split("\") | Select-Object -Last 1

write-host $folder

This should work in all cases of the first deployment and redeployments that include the _1.

I hope this helps, and please let me know how you go!

Best regards,


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.