Xml Transformations based on Role

Hi,

I cannot see any mentioning of it in the documentation, but is it possible to run xml transformations based on Role in an environment?

MyFile...config or similar?

Thanks,
Per

Hi Per,

You can do it based on the environment name, but not the role unfortunately. That’s because a step could target multiple roles, and a machine could be in multiple roles, and it wouldn’t be deterministic as to which one got run or which order they’d get run in. You could set up a variable with different values depending on role, however, and then use the custom XML config transforms setting with your custom variable.

Paul

Paul,

Can you please point me in the direction of “use the custom XML config transforms setting with your custom variable.”. I want to do something similar whereby a config value is dependent on the Machine being deployed to e.g. a config transform like Web.Test.pstest01.config where Test is the environment, and pstest01 is the machine in that environment. I understand about being in multiple roles however.

Stephen

Hi Stephen,

In your package step configuration, you would specify something like this:

Screenshot

(bigger: http://res.cloudinary.com/octopusdeploy/image/upload/v1385871435/Screen_Shot_2013-12-01_at_2_16_33_PM_u7jueh.png)

If your target file is web.config, and you are deploying to a machine named Web01 in your Production environment, this will look for a file named web.production.web01.config.

Hope that helps,

Paul

Hi Paul,

I have a number of test environments (Test1, Test2, Test3) and I want them all to use the same XML configuration transformation.

  1. Is there a way to use same xml transformation across multiple environments?
  2. Is it possible to disable the *.Release.config for certain environments?

Thanks

Hi,

You can create variables to hold the name of the xml tranformation file, and set scopes to them, so the value changes depending on the environment.

For example, let’s say you want to use Web.Release.config for transformations when deploying to Test1 and Test2. But when you deploy to Test3 you dont want any transformations to take place:

  1. Create two variables called “TransformFile” with the following values and scopes

(a) Value - Web.Release.config ; Scope - Test1, Test2

(b) Value - Web.config ; Scope - Test3

For (b), since you cant assign an empty value for the transformation, we are telling the web.config to use itself for the transformation, which will keep the web.config just like it is

See variables.jpg

  1. On the NuGet deploy step, use the variable to set the transformation file. See deployStep.jpg

Hope that helps!

Dalmiro

Thanks Dalmiro, that helped.

Callon