Server variables not available when running Powershell child step

Hi,

I want to use a child step to run a Powershell script below using a server variable OctopusOriginalPackageDirectoryPath, but the variable doesn’t get any value.

$platformsDir = ($OctopusOriginalPackageDirectoryPath + “\EnvironmentConfigs” + $OctopusParameters[‘Octopus.Environment.Name’])

The parameter on the other hand works fine.

Any tips?

Brgds

Jonas

Hi Jonas,

Currently values from one step aren’t available in other steps. For this scenario you’ll need to use the “Custom installation directory” feature on your package step to deploy the package to a specific place, and then reference that place from your script.

For example:

 AppDirectory = C:\Apps\YourApp\#{Octopus.Release.Number}

Then you can tell your package to install to #{AppDirectory}, and in PowerShell you can use files from $AppDirectory.

We have plans to allow these variables to be available from other steps in the future, but for now this is the only workaround.

Paul

Hi,

Ok, that explains it. It would be good to at least be able to use variables from a parent step in a child step, like in the case here. I’ve solved it using a PostDeploy.ps1-file instead.

Brgds

Jonas