Open TomPeters opened 6 years ago
Hey @TomPeters , did you find anything around this ?
@SinghDivneet Not yet. This issue is not high on our backlog right now because it is so risky - it could potentially break lots of deployment processes that are currently working.
I could be missing something here but I'm having a problem using the new AWS CLI templates at all because of this. I need Octopus variables in there or else I can't really us it at all. How is this not a bigger problem. Looking for a work around, but so far not seeing one. I must be missing something because otherwise this seems like a huge miss on the implementation of the Octopus template execution. Oh, I'm using an inline script. Perhaps if I use a pre-created script it will substitute properly. 🤕
To reproduce:
Octopus.Parameters["my-parameter-name"]
At runtime, you will get an error like
ERROR: Script execution failed. [KeyNotFoundException] The given key was not present in the dictionary.
Since the variable value was not explicitly specified as part of the step, it is not included in the variable collection during deployment. If you try to do the same thing in PowerShell, you will end up with a
null
value, due to the differences between the C# dictionary and the PowerShell one.As a workaround, you can use
.TryGetValue
or.Contains
in the C# script to handle the case where the variable has not been defined.There may be people that are currently checking whether the variable exists in the dictionary as part of their scripts, so any changes here could potentially break existing deployments.