Octopus.Action[step_name].Output.Package.InstallationDirectoryPath is empty

Dear Support,

I’ve a PS script running several steps after the referenced action. I am attempting to ascertain the path in which the package was deployed (e.g. F:\Octopus\Applications\Localhost\Coach.Web\20180806.4) during an earlier step. I am doing this to change the permissions of a child folder.

This is the code I’m using to evaluate this output variable:

“Deploy Coach Web” is the step I am wanting to know the Package.InstallationDirectoryPath of"

$myhostname = $OctopusParameters['Octopus.Machine.Name']
Write-Host "Host=$myhostname"
$path = $OctopusParameters['Octopus.Action[Deploy Coach Web].Output[$myhostname].Package.InstallationDirectoryPath']
Write-Host "Path=$path"

Can you please help?

Warmest regards,

Garrard.

Hi Garrard,

Thanks for getting in touch! Using the single quotes (') on your $path variable means everything within these will be treated as a string literal. Using double quotes instead will allow the variable to be evaluated and changing this should give the expected result. It should look like the following. :slight_smile:

$path = $OctopusParameters["Octopus.Action[Deploy Coach Web].Output[$myhostname].Package.InstallationDirectoryPath"]

I hope this helps! Let me know how you go or if you have any further questions moving forward.

Best regards,

Kenny

Hi Kenny,

This unfortunately didn’t work either.

Warmest regards,

Garrard.

Hi Kenny,

I’ve more info on this now. It fails to work when calling from a step in a bundle (deploy a release). However, if I remove the host indexer from the Output array like this:

$OctopusParameters["Octopus.Action[Deploy Coach Web].Output.Package.InstallationDirectoryPath"]

and call from the project itself (and not the bundle) it works:

Path=C:\Octopus\Applications\AWS\Development\Seed\20180807.2_2

Is it designed to run from a bundle?

Warmest regards,

Garrard.

Hi Garrard,

Thanks for following up and clarifying your scenario and requirements. This does in fact work differently when using the Deploy a Release step. You can pass variables to the child project, but you would need to pass each machine-specific variable separately and call them in the child project as you would a standard project variable (i.e. #{VariableName}). Only a single value is given to a variable being passed, which isn’t machine-scoped.

What I did when playing around with this is create these variables in the Deploy a Release step, where each would have their own unique machine-specific value for the installation directory.

I then called them each individually in my child project.

This then outputs the following.

Would this help get you closer to where you need to be? You could theoretically add some logic to only display the relevant value for the specific machine.

I hope this helps! Let me know how you go or if you have any further questions moving forward. :slight_smile:

Best regards,

Kenny

Thanks Kenny. I feel I am getting a better level of understanding now. I appreciate your help.

Warmest regards,

Garrard.

Hi Garrard,

Thanks for following up! That’s great to hear. Please don’t hesitate to reach out if you have any further questions or concerns in the future. :slight_smile:

Best regards,

Kenny

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