Using a Variable as a Dictionary Index


Attempting to use the value of a variable as the index to a dictionary does not appear to work.



The output of this expression is the expression itself, which is the behavior when an expression cannot be resolved.


I’d like to know if this behavior is supported, and if so, what the correct syntax is.

More details

In my particular case, I am creating a Step Template where DeploymentStepName is the name of one parameter (a dropdown list of prior step names, specifically), and I would like to set the value of #{Octopus.Action[#{DeploymentStepName}].Output.Package.InstallationDirectoryPath} to another parameter that will be sent to the script. This expression, however, does not resolve; only specifying the literal name of the step in place of the variable does.

There are other values I would like to query in this template that come from the output of another step like this, so to keep things simpler and faster, I would like to be able to specify the target step once from a dropdown list (already have this working) and be finished configuring the step.

As a workaround, I’ve stopped sending in the path and now just send in DeploymentStepName where I use the $OctopusParameters powershell variable to resolve strings and look up values like so:


I’m wondering if this is a bit of an edge case, because I can’t seem to find anything on the web about it; perhaps it will be of some use to others if I ask here.


Thanks for reaching out. Could you strip down that step template to the shortest possible and then send the exported JSON to me? I think the code will say more than a 1000 words this time around :slight_smile:

Once you send it, I’ll see how I can make it work.

Best regards,