Step Template bug with parameters and matching variable names

We’re using 3.2.4, but I’ve seen this issue for a while (maybe even when we were on 2.x).

If we have a step template with a parameter and the project that uses the step template has a variable with the same name, that variable value will be used instead of the value provided for the parameter.

To recreate:

  1. Create a Step Template with a parameter called STParam - just have it write out the value of the parameter (json included below).
  2. Create a step in a project that uses the Step Template - supply a literal string of “test123” for the parameter value.
  3. Create a variable for the project named STParam with a value of “variable value”.
  4. Create a release and deploy.
    Even though the paramer was given a value of “test123”, it will use the variable value and output “variable value”.

In the step template I’ve tried referencing the parameter via $STParam and $OctopusParameters[“STParam”] with the same behavior.

The only way to get around it is to change the name of the variable in the project (or library variable set - which could impact many projects) or change the variable name in the step template - which breaks the projects using the template when you update - you need to remember what values you had used to re-add them (since you changed the variable name they won’t update automatically).

Here’s the json of the step template to test:

{
“Id”: “ActionTemplates-122”,
“Name”: “Write-Output”,
“Description”: “Just uses Write-Output to write the parameter value to the output.”,
“ActionType”: “Octopus.Script”,
“Version”: 2,
“Properties”: {
“Octopus.Action.Script.Syntax”: “PowerShell”,
“Octopus.Action.Script.ScriptBody”: “Write-Output $STParam\n”
},
“SensitiveProperties”: {},
“Parameters”: [
{
“Name”: “STParam”,
“Label”: “Value to output”,
“HelpText”: null,
“DefaultValue”: null,
“DisplaySettings”: {
“Octopus.ControlType”: “SingleLineText”
}
}
],
"$Meta": {
“ExportedAt”: “2015-12-15T15:49:34.309Z”,
“OctopusVersion”: “3.2.4”,
“Type”: “ActionTemplate”
}
}

Hi,

Thanks for reaching out. We’ll be adding a message on the deployment log for these cases: https://github.com/OctopusDeploy/Issues/issues/2126

You’ll still have to rename the variables though. The recommendation is to use more specific variable names on the step template, as those are generally just used within the template and humans hardly ever deal with them. A prefix for Template-Generated variables like “t” would do ($tSTParam)

Regards,
Dalmiro