Octopus.Tentacle.PreviousInstallation variables empty

I’m trying to follow the steps for getting the previously installed package version listed here and when I’m printing these variables to the console log in PowerShell (as a child step to the download package action) they are all empty/null. I’m using other Octopus parameters without problems earlier in the script and in previous child steps scripts.
I really only need PreviousInstallation.PackageVersion, but I tried echoing all of the available Octopus.Tentacle.PreviousInstallation variables. I’ve also echoed other non-PreviousInstallation variables to show that other Tentacle variables are populating correctly.
It’s running on the deployment target, source code within Octopus.

The code snippet is below:

$lastVer = $OctopusParameters['Octopus.Tentacle.PreviousInstallation.PackageVersion']
echo $lastVer
echo "or?"
echo "$OctopusParameters['Octopus.Tentacle.PreviousInstallation.PackageVersion']"
echo $OctopusParameters['Octopus.Tentacle.PreviousInstallation']
echo "$OctopusParameters['Octopus.Tentacle.PreviousInstallation.CustomInstallationDirectory']"
echo $OctopusParameters['Octopus.Tentacle.PreviousInstallation.CustomInstallationDirectory']
echo "$OctopusParameters['Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath']"
echo $OctopusParameters['Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath']
echo $OctopusParameters['Octopus.Tentacle.PreviousInstallation.PackageFilePath']
echo "$OctopusParameters['Octopus.Tentacle.PreviousInstallation.PackageFilePath']"
echo "Other tentacle things"
echo $OctopusParameters['Octopus.Tentacle.Agent.ApplicationDirectoryPath']
echo $OctopusParameters['Octopus.Tentacle.Agent.InstanceName']
echo $OctopusParameters['Octopus.Tentacle.Agent.ProgramDirectoryPath']
echo "tentacle cd"
echo $OctopusParameters['Octopus.Tentacle.CurrentDeployment.PackageFilePath']
echo $OctopusParameters['Octopus.Tentacle.CurrentDeployment.TargetedRoles']

And the verbose logs are below, where I’ve trimmed the trailing time stamp and Info:

Other tentacle things
C:\Program Files\Octopus Deploy\Tentacle
tentacle cd
<<correct but redacted system role name>>

I’ve had multiple successful deployments before I added this part of the script. I suspected that the PreviousInstallation would return only the last successful deployment version, so I’ve tried purposefully succeeding deploys to the same environment, channel and machine with identical failure results. For creating my packages I’m using OctoPack via a Jenkins script that’s just uses the default time stamp based version (so the version I’m debugging here is 2016.7.28.456). I can pull all the package versions from the Octopus REST API successfully. (That’s actually the goal here is to pull release notes with the package from between the previously installed version and the current version, and it works great on my machine when I fill in the Octopus variables with what I expect.)

I was concerned that it might be related to the fact that I’m using a environment scoped variable for the Download NuGet package ID action. I’ve run into issues with the setup before, but I didn’t think it would affect the later sub-steps and tentacle like this. I’ve also tried echoing the variables in other projects where the Package ID to download is static and got the same results.

I first had this problem with Octopus 3.2, but I’ve since upgraded to Octopus 3.3.24 and then updated Calamari on all deployment machines.

What else can I do to troubleshoot this? I haven’t yet replicated everything on a fresh project, but that would point to it being part of the Octopus or Tentacle install. I don’t know where else to look now other than try to identify the previous version outside of Octopus. At this point I’d almost assume that I’m using these wrong.

What is the expected behavior for these variables? I can’t find much other than a few forums threads in here that others appear to use them without problems.

I’ve spent almost a day tracking this down, so let me know if you need more information.

Hi Colin,

Thanks for getting in touch and providing detailed information about your experience.

I think I spot what may be going wrong: as a child step to the download package action

$OctopusParameters['Octopus.Tentacle.PreviousInstallation.PackageVersion'] will only work when run in the actual package step. If you wanted to make the value available to a child step you would need to set it as an output variable like so:

Set-OctopusVariable -name "MyPackagePreviousVersion" -value $OctopusParameters['Octopus.Tentacle.PreviousInstallation.PackageVersion']

And then consume it:


I hope this helps!



This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.