Have you double-checked that your Variables in the Octopus UI are properly set for the context in which your PostDeploy.ps1 is executing? For example: Environment, Role, Machine, etc.
Yes the Environment, Role, and Machine are properly set. The variable works for transforming *.config files. I’m also assuming that PostDeploy.ps1 runs during the same step (Deploy) as when it transforms the *.config files
The project that I was testing the variables on was just a sandbox project I have setup in Octopus. Once I added the variable and PostDeploy.ps1 to a real project the variable started working.
We are having exactly the same issue. I declared two variables ServiceName and OctopusPackageDirectoryPath to be used by PreDeploy.ps1 and Deploy.ps1. It is a windows service which will be deployed to tow environments and will have a different name and path for each environment. Unfortunately, the powershell script doesn’t read those variables and therefore it installed the service with default name “OctoService”. Is there something we are missing?
Files are attached.