#{if variable name here}true#{/if}

Good morning. I’m following along with the Conditional variables help located here: https://octopus.com/docs/reference/variable-substitution-syntax#VariableSubstitutionSyntax-Conditionalsconditionals

What I want to do is set a Binding on a website deployment to Enabled=false if a variable does not exist. Following the help document I thought that this should work for the ‘Enabled’ expression: #{if ClientRenewalSummary-Website Host Name 2}true#{/if}.

When I use this I get the following error on deployment. What am I doing incorrectly?

Thank you,
Kevin

System.FormatException: String was not recognized as a valid Boolean.
at System.Boolean.Parse(String value)
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.EnsureCertificatesUsedInBindingsAreInStore(VariableDictionary variables) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\Features\IisWebSiteBeforeDeployFeature.cs:line 32
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.Execute(RunningDeployment deployment) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\Features\IisWebSiteBeforeDeployFeature.cs:line 22
at Calamari.Deployment.Conventions.FeatureConventionBase.Run(RunningDeployment deployment) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\Conventions\FeatureConvention.cs:line 82
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
at Calamari.Deployment.ConventionProcessor.RunConventions() in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28
Running rollback conventions...
String was not recognized as a valid Boolean.
System.FormatException
at System.Boolean.Parse(String value)
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.EnsureCertificatesUsedInBindingsAreInStore(VariableDictionary variables) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\Features\IisWebSiteBeforeDeployFeature.cs:line 32
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.Execute(RunningDeployment deployment) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\Features\IisWebSiteBeforeDeployFeature.cs:line 22
at Calamari.Deployment.Conventions.FeatureConventionBase.Run(RunningDeployment deployment) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\Conventions\FeatureConvention.cs:line 82
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
at Calamari.Deployment.ConventionProcessor.RunConventions() in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 50
at Calamari.Commands.DeployPackageCommand.Execute(String[] commandLineArguments) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Commands\DeployPackageCommand.cs:line 120
at Calamari.Program.Execute(String[] args) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Program.cs:line 45
The remote script failed with exit code 100
Website - Client Renewal Summary on XXX

Hi Kevin,

Thanks for getting in touch! I’m sorry you’re hitting this roadblock. This error indicates that it’s unable to evaluate to either True or False. Are you only getting this error when you’re expecting the value to be evaluated as false (i.e. the variable doesn’t exist in the deployment)?

Could you try using the following condition on your binding? Adding the unless should evaluate to false if no variable exists in the deployment.

#{if ClientRenewalSummary-Website Host Name 2}True#{/if}
#{unless ClientRenewalSummary-Website Host Name 2}False#{/unless}

Refer to my attached screenshot showing this. You can also refer to this forum post which provides lots of great info around conditionals on IIS bindings :slight_smile:

Let me know if this helps! If not, which version of Octopus are you running? Can you attach a full verbose deployment log? You can refer to our documentation to get this full log.

Best regards,

Kenny