Why is it so hard to get the current installation path!?

We’re using Octopus to deploy websites to IIS.

I’m working on a Powershell script to run during deploy, my idea is to add this script the “Script Modules” inside the Library of Octopus.

I would like to copy some files from the previous version to the newly deployed.

Getting the previus deploy path is easy: $OctopusParameters[‘Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath’]

But I need to get the folder to the current deploy, I’ve found this:

$OctopusParameters[‘Octopus.Action[Deploy to Test].Output.Package.InstallationDirectoryPath’]

But in this the “Step” is hardcoded “Deploy To Test” and since i want this to be a script module I can’t know for sure that the name of the steps will always be the same.

How can I get my hands on the current path of the installation inside a script without having to hard code the step?

Hi Markus,

Thank you for reaching out to us with your query.

A deployment process can contain multiple “Deploy A Package” steps. This means that, unless the step name is specified, the script wouldn’t know which of the deployed packages is being referenced. This is why there is no equivalent to the Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath variable.

One way to address this could be to change the hardcoded step name to a variable which is populated elsewhere in the process. For example, you could set a project variable (e.g. packageStepName) which contains the name of the required step and then reference it along the lines of $OctopusParameters['Octopus.Action[$packageStepName].Output.Package.InstallationDirectoryPath'].

The other possible option would be to change your package deployment steps to use a Custom Installation directory. The custom installation directory could then be bound to a project variable (e.g. packageInstallPath) and you could then reference that variable in your script instead of using the InstallationDirectoryPath system variable.

There are some drawbacks to both approaches. For example, needing to modify your existing deployment processes to either use the custom directory variable or to set the step name variable. The best option will depend on your specific requirements.

I hope this is helpful. Please let me know if you have any questions.

Best Regards,

Charles

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