External .xml file

I have an external Settings.xml file which resides in a different directory. I know there are options to use variables for .config files but how to replace the XML element. See the below example? I need to create a variable that will be used by Octopus to replace configurations\credentials\app\password node in the below Settings.xml file. This needs to be done during Deployment Time. Please help.

True true E:\PR\PRD\AppServer\LogFiles appuser1 appPassword1 dbuser1 dbPassword1

Hi @pankajrayal,

Thanks for getting in touch!

Just to clarify, this Settings.xml file currently doesn’t exist within Octopus or get deployed by Octopus? It is a static file on the target that you wish to update values within?

If that is the case, then there are two options I can think of.

The first would be to write some Powershell to perform a find/replace on the required values and use Octopus variables for the replace part of the script. This doesn’t feel like a particularly clean solution though.

The second option would be to add a new package to Octopus that contains a template of the Settings.xml file. In this template, you would amend the values you want to change to Octopus variables e.g. #{appUser}. Then add a step deploy a package step to your deployment process with the custom install location and substitute variables in files features enabled. This will then replace the values as needed and deploy the file to the desired location, overwriting the file that is already there.

I hope this helps, please let me know if you have any further questions.


Thank you for your reply Paul.

The Settings.xml file is part of the package being deployed on the server. So every package will have one settings.xml file.

Perfect, in that case the second option with some modifications should work for you.
Basically, amend the XML values to octopus variable names, enable the substitute variables in files option and configure the variables within Octopus.

Thanks Paul.

I am new to octopus to I still need to figure out how to do that. I will appreciate if we have some example/sample to do that. It’s been a long day of trying multiple things and nothing works…!

Appreciare your help.

The links I provided include steps on how to accomplish this and some samples but we also have a blog post with some additional information too.
To use a web.config file as example. If I wanted to change the value for <authentication mode> I would amend the file included in the package to include a variable name #{authMode} in place of the value:

    <authentication mode=#{authMode} />
    <compilation debug="true" targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />

Then in Octopus a variable would be created for this variable:

And the substitute variables in files feature would be configured within the package step:


Thank you Paul. That solved my problem.

1 Like