Access dynamic step variable from PowerShell

usability
server
(It Group) #1

Hi,

I am trying to access a variable from a previous step defined as a “Previous Deployment Step name” parameter from PowerShell.

Regular syntax for static step name is:

$PrevStepParam = $OctopusParameters["Octopus.Action[PrevStepName].Output.Param"]

However what would the syntax look like for dynamic PrevStepName?

I would need something like the below, but cannot figure out the right syntax:

$PrevStepParam = $OctopusParameters["Octopus.Action[$OctopusParameters['PrevStepName']].Output.Param"]

Thank you in advance.

(Kenneth Bates) #3

Hi @it_group,

Thanks for getting in touch! Unfortunately I don’t think we’d have a great answer on how to achieve this, since the previous step name isn’t stored in any system variable, and output variables won’t work since you have to specify the step name that created the output variable. Currently I think the only option (which certainly isn’t nice) would be to write the relevant step name to a text file which you could then read out when needed.

I’d be happy to try to think of any potential out of the box ideas. Can you elaborate a bit on what you’re trying to achieve and what you’re requiring?

I hope this helps, and I look forward to hearing back!

Best regards,

Kenny