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
_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.
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
This should work in all cases of the first deployment and redeployments that include the
I hope this helps, and please let me know how you go!