Can't get a web application to deploy; variable substitution not working?

I’m having a bit of a problem with variable substitution and different target machines.

I’m deploying a web site, which deploys just fine to the test server, but when it comes to deploying to staging, the variable substitution for the parent web site doesn’t seem to be happening.

The variable in question as defined in the variables:

variable name: IIS_Parent.Site.Name:
value: Default Web Site
scope: StepName, LocalTestMachine, WebserverRole, LocalTestEnvironment

variable name: IIS_Parent.Site.Name:
value: Staging.Parent.Site.Name
scope: StepName, StagingMachine, WebserverRole, StagingEnvironment

It deploys to the local test machine, whose parent site is Default Web Site, deploys just fine, but when trying to deploy to staging, an error is generated:

The Web Site “#{IIS_Parent.Site.Name}” does not exist in IIS and this step
January 24th 2017 20:48:52Error
cannot create the Web Site because the necessary details are not available.
January 24th 2017 20:48:52Error
Add a step which makes sure the parent Web Site exists before this step
January 24th 2017 20:48:52Error
attempts to add a child to it.

Things I’ve noticed, things I’ve tried:

  • The parent site on the staging server is Staging.Parent.Site.Name, but it has several other sites as well, unlike the test server, which has only the default site.

  • I noticed the error displays the untransformed variable name, rather than it’s expanded value: that seems wrong… for grins, i changed the value for test to something incorrect; in that case, the error message reported the value of the variable, rather than the variable name; that is, the variable name substitution took place as it should have in the local case, and was reflected in the error message.

  • the staging parent site is ssl, and the local test parent site is not; does that make a difference?

  • I tried simplifying the variable name to PSN… same error; works on local, but get the same error on staging

  • I tried changing the value of the staging variable to another site on the server… again the same error.

  • the snapshot of the variables shows the correct value for both environments

  • replacing the variable with the actual parent site name in the web application deploy step makes everything deploy correctly to the staging machine

In fact, none of the user defined variables are being expanded in this environment! The web.config settings are being replaced correctly, and the Octopus variables are as well, but none of the ones that I defined are working for this environment/target. Since they are working for the test environment/target, there must be something i’m forgetting to set?

thanks in advance…

Things are working now. I instantiated another environment, and added target with different ip that points to the same server. Then i changed the scope of all the variables to point to the new environment. (the initial staging environment/target still does not work).

it seems that something association didn’t get set in a database somewhere.

i continue to have trouble with variable substitutions expanding.
in the latest, one of my web config variables is called
’versionString’, which is entered, unscoped into the variables section of the octopus project.

the string looks like this:

In settings, i set the version to the variable #{versionString}.

In the UI when I create a release, Octopus displays the expanded version of the string; however, in the web.config, the version string reads:


I’m obviously missing something… can you please tell me what it is?

thanks in advance

this seems very similar to this question…

so i followed the steps there, and got a raw log file…

ServerTasks-57.log.txt (55 KB)


Thanks for reaching out! Also thanks for sending that deployment log.

Could you please also send us the following so we can help with the troubleshooting:

  • Screenshots of how your variables are set in Octopus. I’m looking forward to see their names, values and scopes.

  • Your Web.config file just like it is on the package (meaning pre-transformation).


thanks so much for you attention to this. the files requested are incuded

Web.7z (1 KB)

oh… here is the screenshot…


Thanks for sending all that info. I see what is going on now:

The variables #{Octopus.Date.Year}#{Octopus.Date.Month}#{Octopus.Date.Day}.#{Octopus.Time.Hour}.#{Octopus.Time.Minute} are only available in the context of the Version template, and not during the deployment itself (which is what you are trying to do).

What you can do is create that variable in Powershell in the Pre-Deploy Script field of your package step by using the below snippet instead of creating if as a project variable.

[datetime]$rawdate = $OctopusParameters['Octopus.Deployment.CreatedUtc']
$formattedDate = $rawdate.ToString("")
Set-OctopusVariable -name "versionString" -value $formattedDate

Since its running as a pre-deploy script that would make the variable versionString available during variable replacement execution, holding a date value with the format “”.

Hope that helps,

that works. thanks so much for your help.