When promoting or deploying a build, I’d like to automate swapping out a single database connection file. This could be done as either a post-build step or as a pre-packaging step before deployment.
The file that’s being swapped out is a test file; the file being swapped in should have the real database connection configuration.
How can this be done? I use Hudson as the CI server, if that helps, and use GitHub for SCM.
Manual swapping of the files, IMHO, is fraught with human error and can be altogether forgotten. Plus it adds just one more thing to do and impedes the momentum of a continuous deployment cycle.
Maybe you don’t need to replace the entire file. As part of a deployment script we use powershell to read the config file and use a bit of xpath magic to find and change the database connection strings to test/production settings depending on where we’re deploying.
Effectively its a search and replace.
The following is a snippet for modifying a .NET web config file but the same could be done for other xml based configuration files.