In previous posts (I and II) we have seen how to configure Release Management and an environment to work with. Now it's time to configure our first release to see how a modification in the code could travel from our Visual Studio to production.
Go to Configure Apps -> Release Templates.
Click on New and fill the basic information.
Click on Edit button next to Build Definition textbox and select the build that the release will use.
As you could see, you have an empty release template. You could see the three stages defined in our release path (see II) with an empty deployment sequence. Our work now is to fill this deployment sequence to be able to deploy the website we've created using Visual Studio.
To do this we will need to create a new component. We will use components to deploy an application. In our case, we are going to create a component to copy the files of the web site from build folder to IIS folder. So, right click on components and click on Add.
Choose a meaningful name for the component and select XCopy deployer tool. As you can see, there are a lot of options to be able to deploy correctly your application. Choose the right one for your project.
Click on Configuration Variables. As we will see later, we can tokenize our deployment. We can define some tokens in some files of our project (in web.config in our case) that will be overwritten by the values defined in the release template. For example, we will change the server IP and the database connection for all three environments.
So, let's create two configuration variables, one for server and one for connection string. Choose after installation as replacement mode and limit the file extension filter to *.config.
Let's start configuring the deployment sequence for Dev stage. Drag the server node and drop into deployment sequence. Then, drag the brand-new component into the server.
Double click on the component to view it. The configuration variables will be shown in order to be filled. Fill them with the right information. In our case we have three websites configured in IIS, each of them with a different port and a different folder. We also want to create three different databases.
In order to deploy correctly our website, we need to make one more step. We need to copy a folder from its original location to another one. To do that, we will use an item of release toolbox called Copy File or Folder.
Go to the toolbox and expand Windows OS node. Drag Copy File or Folder node and drop after the component just configured.
Double click on the item and configure the variables.
So now we've created the deployment sequence for Dev environment. In our case, the deployment sequences for the next two environments will be pretty the same, only the configuration variables will change.
Right click on Dev stage and select Copy Deployment Sequence.
Right click on QA stage and select Paste Deployment Sequence.
We will be asked to map servers when we paste a deployment sequence from one stage to another. In our case, we only have one server, so the mapping is very easy.
We are close to deploy the application! We only need to create the token file and to configure a build that fires a deploy. Let's start with the token file.
Go to your solution and copy web.config file. Rename the file to web.config.token. Change the string you want to tokenize to the configuration variable's name, starting and ending with a double underscore.
Before creating the new build definition, we have to upload an specific Build Template to TFS. You could find the template in this location: C:\Program Files (x86)\ Microsoft Visual Studio 12.0\ReleaseManagement\bin. If you want add the release management features in an existing build template, please refer to Release Management User Guide.
We could create now the new build. Create a new Continuous Integration build based on ReleaseDefaultTemplate template and with Release Build parameter set to true.
And that's all we have to do. Make a change in your code, check in pending changes and when the build finishes we can see how our application is travelling through the release path.
Go to Releases -> Traffic Overview. Take a look to your release path. You could see there's one App in traffic. Depending on how you have configured the release path, you will need to accept some steps or not. In our case we have to accept all the intermediate steps.
Go to Releases -> My Approval Requests. Refresh the view until you see an approval request. If you have configured mail notifications, the approver will receive an email.
Approve all the notifications.
When the notification to deploy to production arrive (all the other deployments are automatic) you have to specify a little more information.
And finally the traffic overview will look like this.
As you can see, the application has traveled through all the release path. Now we can open our favorite web browser and take a look at the three web sites.
And that's all for today. Enjoy your holidays!!