Using previous step variable when that step failed

I’m deploying a windows service, and after deployment I want to set the security so a custom account has read access to the folder where the service is deployed by octopus.
The deployment of the service fails, because it is configured to run under the custom account which does not have read access yet. This is something of a “which was first, chicken or egg” problem.
Which might easily be solved.

I’m using this variable, and it’s not replaced on failure of the previous step.
#{Octopus.Action[Install Windows Service].Output.Package.InstallationDirectoryPath}

But it shouldn’t really be empty, because the installation directory was correctly used and the application was deployed in that folder.
In the log the variable should be replaced, because it works on previous steps where I do something similar and the log output contains the actual folder names.

I believe I can work around this issue with additional steps at the end, but wanted to let you guys know this. Maybe it’s a bug, maybe it’s not…

Hi David,

Thanks for getting in touch! There is a special way to call variables in PowerShell scripts. The syntax is slightly different
So instead of #{Octopus.Action[Install Windows Service].Output.Package.InstallationDirectoryPath} can you try $OctopusParameters["Octopus.Action[Install Windows Service].Output.Package.InstallationDirectoryPath"]

Here’s some follow up documentation:

Hope this helps!

That didn’t seem to work either.
But the workaround I have is ok.