Deployment of same artifact to different environements
Asked by Phil Carter:

Hi All

Just wondering if anyone can give me some ideas on solving an issue we currently have with our Bamboo builds and subsequent deployments.

We have a single .Net website project that needs to be deployed in a couple of "flavours".

1. the main production instance
2. a demo instance
3. a training instance

Each of these instances have a slightly different configuration.

At the moment, when we run a release build the project esssentially gets built three times, once for each instance, which generates three seperate artifacts. This process chews up quite a lot of build time, and vastly increase the space used for build/artifact storage.

Is it possible to have the build generate a single artifact, and then in a post-build task, or pre-deployment task, make the necessary configuration changes for each instance?

Cheers

Phil


Answers:
author: Jimmy Seddon
body: Hi Phil,

Welcome to the Community!

At a high level you have already described exactly what needs to be done. The question that I feel needs to be asked at this point is "what" is different configuration-wise between the three artifacts. I know for some of our older .net websites, we are storing configuration changes per environment in a separate repository and we are using powershell scripts to replace environment specific configuration settings in the app.config and web.config files ahead of deploying to the selected environment. Not sure if that suggestion will be helpful or not.

Good Luck!

-Jimmy


author: Phil Carter
body: [@Jimmy Seddon](/t5/user/viewprofilepage/user-id/3746309) yes, I think it's just the configs that are being transformed as part of the build.

The thing I'm trying to solve is not building the same project over and over again.

Sorry, I'm not very clear on the build options available in Bamboo. Could we have seperate build that does the config transforms and outputs those as different artifacts? Then bring the main build artifact and the config build artifact together in a deployment plan?

Cheers

Phil

comments: author: Jimmy Seddon
body: Hey [@Phil Carter](/t5/user/viewprofilepage/user-id/4029704),

Ok let me try to explain what we are doing a little more clearly. I want to preface this with what we are doing is not pretty but it works and we haven't found a better way ourselves. We only build the .Net website once with values for the development environment, and save that as our built artifact.

Then, we have a deployment project with QA, Staging and Production environments. When we execute one of those environments from our deployment project in Bamboo it does the following:

1. Downloads the artifact from the build plan (which contains dev values from our single build)

2. Checks out our configuration repository that contains all config values for all environments.

3. Run a PowerShell script that based on the environment we are executing does XML find \& Replace to update the development values to what they should be set to for the environment we are executing.

4. Deploy the website to the correct servers.

So we are in fact only building it once. We aren't using proper web.config transforms to map the configurations at build time we are doing it using a Powershell script at deployment time.

I hope that makes more sense for you.

-Jimmy


author: Phil Carter
body: [@Jimmy Seddon](/t5/user/viewprofilepage/user-id/512822) yep, that makes sense and will give me something to work on.

Cheers

Phil