OctopusDeploy / Issues

| Public | Bug reports and known issues for Octopus Deploy and all related tools
https://octopus.com
161 stars 20 forks source link

Step template parameters not included in variable dictionary unless a value is provided in a step #4191

Open TomPeters opened 6 years ago

TomPeters commented 6 years ago

To reproduce:

  1. Set up a step template, which has a single parameter. Don't specify a default value and make the type "Single-line text box". Make the step a C# script and in the body of the script, access the parameter value by using Octopus.Parameters["my-parameter-name"]
  2. Use the step template in a deployment process. Leave the parameter value alone, don't enter anything in the field and do not override its value with anything.
  3. Deploy the project.

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.

SinghDivneet commented 5 years ago

Hey @TomPeters , did you find anything around this ?

TomPeters commented 5 years ago

@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.

ebol2000 commented 4 years ago

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. 🤕