Multiple IIS bindings for some environments

I am setting up a large number of projects to be deployed to a dedicated server using Octopus Deploy, most projects have both a staging site and a production site.

For the staging sites, there is usually just one binding, such as “client-staging.blah.com.au”

For production sites, there are usually two bindings, being “blah.com.au” and “www.blah.com.au”.

I’m using a variable against each project for the Binding host name, called “BindingHostName” which i’m setting to “client-staging.blah.com.au” for the Staging environment, and “www.blah.com.au” for the Production environment, but how can I also selectively add the second binding for only Production?

At the moment my workaround is to create a second variable for “BindingHostNameOther” which I set to something that will never be used for Staging (as I found the deployment fails if I leave it out for Staging), and set to “blah.com.au” for Production.

Thanks
Bron

Hi Bron,

Thanks for reaching out!

Your approach is not at all bad, but there’s a more elegant way to do it:

If you click on “Edit” on a binding, you’ll see it has an “Enabled” checkbox in it. If that box is checked, the binding will be added to the site. If its not, then It’ll be ignored by Octopus.

What you can do is, instead of using the raw checkbox, use a custom expression with a variable instead. If this variable resolves to the string “true” It’ll be as if the box was checked. “false” would do the opposite.

You can play with that variable and some environment-scoping to decide if a binding will be used or not when deploying to a especific environment.

Hope that helps!
Dalmiro

Oh awesome, I hadn’t noticed the little box on the far right for that purpose, for that field – thanks Dalmiro, I’ll do that!

Works a charm, thanks again!

Glad to hear that!

Hello,

I’m trying to do this exact thing and I keep getting the error below with any variable that tries to enable/disable a binding during the step.

11:45:42Error
At C:\inetpub\wwwroot\ARCTools\Octopus.Features.IISWebSite_BeforePostDeploy.ps1:120 char:6
11:45:42Error
+         if([Bool]::Parse($binding.enabled)) {
11:45:42Error
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11:45:42Error
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
11:45:42Error
    + FullyQualifiedErrorId : FormatException
11:45:42Error
11:45:42Error
Script 'C:\inetpub\wwwroot\ARCTools\Octopus.Features.IISWebSite_BeforePostDeploy.ps1' returned non-zero exit code: 1
11:45:42Error
Running rollback conventions...
11:45:42Error
Script 'C:\inetpub\wwwroot\ARCTools\Octopus.Features.IISWebSite_BeforePostDeploy.ps1' returned non-zero exit code: 1
11:45:42Fatal
The remote script failed with exit code 1```

The variable in the system is just the text "true" or "false", without the quotes.

I am using version 3.3.26 on the server and the tentacles. What am I doing wrong here?

Hi there,

Can you send me a screenshot of how your binding variable looks like? Also please follow the below instructions and send a deployment process so we can see what happened in more detail.

1) Add these 2 variables to your project http://docs.octopusdeploy.com/display/OD/Debug+problems+with+Octopus+variables

2) Create a new release (so the new variables take effect) and deploy it. If possible skip as many steps as you can and only leave step we are troubleshooting in order to avoid the noise in the log.

3) Send us the raw log of that deployment http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task

Best regards,
Dalmiro

Hello,

Attached are the screenshot and the log you asked for. Please let me know
if there is anything else to help figure this out.

[image: Inline image 1]

ServerTasks-6460.log.txt (18 KB)

Thanks for that info. Unfortunately your log isn’t showing the verbose info I was looking forward to see. Did you follow steps 1-2?

1) Add these 2 variables to your project http://docs.octopusdeploy.com/display/OD/Debug+problems+with+Octopus+variables

2) Create a new release (so the new variables take effect) and deploy it. If possible skip as many steps as you can and only leave step we are troubleshooting in order to avoid the noise in the log.

3) Send us the raw log of that deployment http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task

(1) tells you to add some variables to your projects, and (2) asks you to create a new release to the 2 new variables take effect.

Additionally please send me screenshots of the bindings configuration of your package deploy step. Make sure all of them can be seen in the image