How to get the child step name with powershell?

I got a “Deploy to IIS” step defined and run a powershell script in Deployment Script within Custom Deployment Scripts. I need to get a path to the installed application. The following script works well when defined in the parent step

$stepName = $OctopusParameters[“Octopus.Step.Name”]
Write-Host $OctopusParameters[“Octopus.Action[$stepName].Output.Package.InstallationDirectoryPath”]

However $OctopusParameters[“Octopus.Step.Name”] returns the parent step name even when executed in the child step. Is it possible to get the value of the child step name using system variables?

Hi Darius,

Thanks for getting in touch! Child steps are available as Octopus.Action parameters. Only top level steps (parent steps or steps that don’t have any child steps) are available as Octopus.Step. You should be able to get the expected result within a child step by tweaking your script to match this:

$childStepName = $OctopusParameters[“Octopus.Action.Name”]
Write-Host $OctopusParameters[“Octopus.Action[$childStepName].Output.Package.InstallationDirectoryPath”]

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

Best regards,

Kenny

1 Like

Hi Kenny, it works well, thanks a lot for help!

Regards
Darius

Hi Darius,

That’s great to hear that worked for you! Thanks for letting me know, and don’t hesitate to reach out if you have any questions 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.