Step template with script parameters, empty variables not substitued

I am creating a step template which uses a script package and script parameters.
The script parameters are supplied as such:
-address "#{address}"

In this case, #{address} is optional, as in an empty value is acceptable. I would have expected when running the step with no value provided for address, Octopus would replace "#{address}" in the script parameters with an empty value, eg. "". However, it does not, which means in my script I have to have a check: if ($address -eq "#{address}") { ... }

Is this expected behavior?

Hi Sean,

Thanks for getting in touch. It currently is working as expected, the value it will have if not supplied is actually $null.

If you run this code, without supplying address, you’ll see it in action:

$a = #{address}
if ($a -eq $null) {
 Write-Host "address was null"
}

You can better test for that, $null is a better reflection of the fact it was not supplied, instead of empty string because that’s not the same thing as null. Another thing you could try is setting a default value option as part of setting up the address parameter on the step template, but that depends on your objective.

Hope that helps!

Nick