Use Path from Package Deployment in Later Step

Hi,

I’ve looked through the documentation and combed the forums, but I can’t seem to find an answer to this question.

I am trying to capture the path in one step and use it in a later step.

In the first deployment step, I run a post-deployment script to set a variable:

$PathVariable= $OctopusParameters[“Octopus.Action[‘STEP NAME’].Output.Package.InstallationDirectoryPath”]
Set-OctopusVariable -name “PathVariable” -value $PathVariable

Unfortunately, this does not change the value of the variable PathVariable. It appears to do nothing.

What am I missing?

Thanks,

  • Henry

Hi @Henry.LaFleur,

Thanks for reaching out. Sorry to hear you’re having issues.

It looks like you are trying to reference the location where the package is extracted in a later step. Assuming that is the case, here is what I recommend:

Either in a post-deploy script or a Run a Script step, you may define your output variable like the example below:

$Path = $OctopusParameters["Octopus.Action[Package_Deployment_Step_Name].Output.Package.InstallationDirectoryPath"]
Set-OctopusVariable -name "PackagePath' -value $Path

To retrieve this value in a script later to be used, you must reference the name of the step in which you created the variable.

$OctopusParameters["Octopus.Action[Variable_Creation_Step_Name].Output.PackagePath"]

The last part ‘PackagePath’ will be the name defined for Set-OctopusVariable.

If this doesn’t make sense or isn’t quite what you were looking for, please don’t hesitate to reply back and I’ll be happy to assist further!

Regards,

I’m not following. I need to pass this to another task. I added this to pass a parameter to the task:

It comes across like this:

“#{Octopus.Action[‘DEPLOYMENT STEP’].Output.ProcessingPath}\My.exe”

When I expect:

“C:\Octopus\Application\PathToExe\My.exe”

If I use a variable I set manually or per environment it works, but the output variable for some reason cannot be read.

Am I specifying the step name correctly as ‘DEPLOYMENT STEP’ or is there some mnemonic I need to use like DEPLOYMENT_STEP or some other secret handshake?

Thanks,

  • Henry

Hi Henry,

Thanks for following up! I’ll jump in here quickly as Adam is currently offline as part of our UK-based team. :slight_smile:

When calling this output variable, you’d need to make sure the 'DEPLOYMENT STEP' part exactly matches the name of the step in your process that created the output variable. And the ProcessingPath is where you specify the exact name of the output variable that that step created. However I think there will be an easier way to call this value.

Octopus by default will create some output system variables during your deployment, where the one that I believe you’re requiring would look like Octopus.Action[Your Step Name].Output.Package.InstallationDirectoryPath. This means you shouldn’t have to worry about creating this custom output variable to store this value, and calling that in the next step.

In your step, there’s a #{} icon, where when pushed it’ll populate a dropdown showing all the available variables for that step. If you search for the above variable (InstallationDirectoryPath) and click it’ll insert it into the step with the correct syntax. This will look like the screenshot below.

I hope that helps, and please let us know how you go.

Best regards,

Kenny

OK, I got it.

My problem all along was I was putting the step name in single quotes (which I thought was required because I have spaces). It’s working now. Thanks!

Hi @Henry.LaFleur,

Thanks for letting us know you’re up and running!

If you have any other questions feel free to get back in contact again!

Kind Regards,
Adam

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