Conditional variable values

Hi,

I’m trying to bind conditionally a field to boolean value:

#{if #{Octopus.Environment.Name} == “PROD”}True#{/if}
#{if #{Octopus.Environment.Name} == “DEV”}False#{/if}

So that when the deployment runs on PROD, the result will be true, if “DEV”, false.
This is for to enable SSL bindings for a website on specific environments.

But I get an error

Exception calling “Parse” with “1” argument(s): "String was not recognized as
11:39:05Error
a valid Boolean."
11:39:05Error
At C:\inetpub\wwwroot\PP\Octopus.Features.IISWebSite_BeforePostDeploy.ps1:99
11:39:05Error
char:6
11:39:05Error

  •     if([Bool]::Parse($binding.enabled)) {
    

11:39:05Error

  •        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

11:39:05Error
+ CategoryInfo : NotSpecified: (:slight_smile: [], ParentContainsErrorRecordE
11:39:05Error
xception
11:39:05Error
+ FullyQualifiedErrorId : FormatException
11:39:05Error
11:39:05Error
Script ‘C:\inetpub\wwwroot\PP\Octopus.Features.IISWebSite_BeforePostDeploy.ps1’ returned non-zero exit code: 1
11:39:05Error
Running rollback conventions…
11:39:06Error
Script ‘C:\inetpub\wwwroot\PP\Octopus.Features.IISWebSite_BeforePostDeploy.ps1’ returned non-zero exit code: 1
11:39:06Error
The remote script failed with exit code 1

How can I do it correctly?

Thanks,
Daniel

Hi Daniel,

Thanks for reaching out. Conditional binding don’t quite work that way. I recently posted on another thread a walkthrough that shows how to get this done. It is for a different field, but the same can be applied for the SSL binding.

http://help.octopusdeploy.com/discussions/questions/5779#comment_38717220

Hope that helps,
Dalmiro

Thank you, that article did the trick.