Set project variable value in Step1 Post-deploy script


I’m not familiar with PowerShell, so sorry if my question is stupid.

So, lets image we have Ctopus project with 2 steps (all Deploy Nuget). Also we have project variable called “ExecutablePath”.
I want to set value for this variable in Step1 post-deploy script and that use it Step2 for “Configuration variables” feature.

So I want to add in Step1 Cutom PowerShell scripts and write something like:
Set-OctopusVariable(“ExecutablePath”, $OctopusParameters[‘Octopus.Action[Step1].Output.Package.InstallationDirectoryPath’])

Is it possible to do this? If yes, what PowerShell command do I need to use.

Thank you.

Hi Yevgeniy,

Thanks for getting in touch! You can call $OctopusParameters['Octopus.Action[Step1].Output.Package.InstallationDirectoryPath'] directly in the Configuration Variables feature without having to define a new Octopus variable. (Please see attached screenshot)

However for when you do wish to define one use the following syntax within PowerShell:
Set-OctopusVariable -name "TestResult" -value "Passed"

Hope this helps!

Hi, Vanessa.
Unfortunately it didn’t work.
I have variable ConsoleExecutablePath defined in project variables (for test I assign value “test” to it).
In my first step () (Nuget package) I have custom Post-deployment script:

Write-Host $ConsoleExecutablePath
Set-OctopusVariable -name "ConsoleExecutablePath" -value "$OctopusParameters['Octopus.Action[Step 1].Output.Package.InstallationDirectoryPath'])"
Write-Host $ConsoleExecutablePath

If I deploy release, in log I get


But I expected to get something like


I have also tried

Write-Host $ConsoleExecutablePath
Set-OctopusVariable -name "ConsoleExecutablePath" -value $OctopusParameters['Octopus.Action[Step 1].Output.Package.InstallationDirectoryPath']
Write-Host $ConsoleExecutablePath

Result the same.

Due to this discussion I figure out that Set-OctopusVariable has scope of only one step.
So, please correct me if I’m wrong - I cannot set project variable value in one step, so I can use this new value in another step later.


What version of Octopus are you using? The discussion linked is very old, and was true back then.
Have you seen the following blog post:
Maybe this will help you. Based on your below example do you have a step named ‘Step 1’ ?
It needs to be the actual step name.

To help you with a specific example I would need a screenshot of your process and the configuration inside your first step.