Ordering of Variable Substitution and XML transformation causing issue

I got a scenario where I grab DB username/password/server/db name from a password repository using Powershell. I store those values in output variables. I have been trying to figure out how to use these output vars in my web.config file.

So I did this:
Created web.#{Environment}.config transformation file
In that file I have:

I enabled Substitute Octopus Variables in files and XML Configuration Transforms. But it’s a no go. My end result web.config is with the #{…} variable placeholders.

In searching I found this article where makes sense why I have this issue http://docs.octopusdeploy.com/display/OD/Package+deployment+feature+ordering

Substitute variables executes before XML Transforms. If it was the other way around this would work.

Is there a way I can create a script step to run Octupus’ Substitute Octopus Variables in files feature using Power shell? That way I can run that after my deploy step.

Or does anyone have another idea, how to use output variables to transform connection string in web.config?

Hi,

Thanks for reaching out. Your initial approach was correct and should be working. Just to make sure we are on the same page, this is the order of how things should go:

  1. A powershell step that creates the output variables should run

  2. [On the package deploy step] Web.#{environment}.config should be the one with the variables that will be replaced by the values harvested in step 1. First the variable replacements should take place.

  3. Once 2 is done, Octopus will move on with the Config transform, putting the values of Web.#{environment}.config (which at this point should already have the values of the output variables on it) into the web.config.

If you have it configured as described above already, please follow the steps below and send us your deployment log so we can see what might be going on.

  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

Dope,

That works, do the variable subsititution on the web.{#environment}.config transform file, instead of the web.config. And put the variable place holders in the transform file.

Thanks.

Glad to hear its working! Ideally, the web.config has to be as dumb and empty as possible, and all the magic should happen on the transform files.

Happy deployments!