Skip to Content

Introduction

Continuous integration (CI) and continuous deployment (CD) help in reliably deliver quality apps to the customers at a faster rate. From code through build, test, and deployment is defined efficiently and fully managed pipelines that automate and control the entire process.

With Continuous Deployment, every change that is made is automatically deployed to production/dev/staging environment. This approach works well in enterprise environments where we plan to use the user as the actual tester and it can be quicker to release.

This blog post provides an idea about setting up the CI and CD pipeline for any project in Team Foundation Server and run the automated builds and deployment from that.

Continuous integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is verified by automated build, allowing teams to detect problems early.

 

Continuous Delivery  is the extension of CI: an approach in which each team ensure that every change to the system is releasable, and we can release any version at the push of a button.

Continuous Deployment (CD) is similar to Continuous Delivery. Here, once the developer commits the code it will go to production without any manual/human intervention.

 

CI/CD Pipeline –  It is the backbone and one of most important part of DevOps. Here we create smooth and seamless pipeline/workflow right from Coding till deployed to production.

Team Foundation Server aka TFS is a Microsoft product which is serves as a SCM tool like Git. It also has features like reporting, project management, automated builds, testing and release management capabilities.It covers entire lifecycle, and enables DevOps capabilities. TFS can be used with numerous IDE including Visual Studio and Eclipse on all platforms.

It also provides the features of implementing both CI and CD. It has the feature of Build Management which includes build process management and automating build triggering. It supports good number of automated build triggers such as scheduled build, Continuous Integration trigger, etc.

Problem Statement

When the development is done and the testing team wants to check the functionality then build is released to the different test environments and this activity is handled manually for most of the projects. Manual build deployments takes lot of time and requires user interactions. Also manual build deployment have challenges such as handling the build version number, cost of the development is more because of maintenance, requires more team engagement and organization.

Solution

To overcome all the challenges and dependencies of manual build deployment process the Automated Build deployment is the best solution and the Build automation is the process of automating the creation of a software build and the associated processes including: compiling computer source code into binary code, packaging binary code, and running automated tests.

Now let us see how to set up the CI-CD pipeline using TFS.

 

Prerequisite for set up CI & CD using TFS

  1. Admin Permissions for the TFS
  2. Set up build agent for running the builds from the TFS build definition.

     Set up Admin Permissions for TFS

When configuring a user in the Team Foundation Server administrator role, you must set permissions in Team Foundation Server groups.

1.From the team page on TFS, click the to go to the team administration page.

2. Add an administrator.

 

Set up the Build Agent

For the TFS navigate to the Agent Queues section and select the option to download agent.

Get the Agent based on the system pre-requisite.

Create and configure the Agent as specified in the above screenshot.

After downloading and creating the agent contents will be displayed in the folder structure like below:

Run the Agent in the Admin mode. For running the builds and release the agent should be running always.

 

Set up the Continuous Integration using TFS

Create a build definition

Login to Team Foundation Server as Admin and Create a Build Definition.

Go to Build & Release tab and navigate to Builds section.

Click on +New to create a new build definition.

 

Choose template for the new build definition

For the TFS there are multiple options present for creating a build definition such as Maven, Jenkins, Xamarian.Android etc. Based on your application select the template.

Select the Visual Studio template and for build and run tests from visual   studio. For Visual Studio template Build Agent is required.

 

Select the repository settings for the build definition

Select the repository source and the default agent queue for running the build definition.

For the Build definition multiple options are present for build, variables, triggers, repository and History.

These options help the user to maintain the build definition.

 

Multiple build steps can be added to the build template selected.

Click at Build steps and a task catalogue is opened and from this select the options for Build, Utility, Test, Package and Deploy based on the application requirements.

 

 

 

 

 

Configure the variables for the build definition.

Variables section for the build contains the list of predefined variables and for this section more variables can be added.

Variables are accessed for the build as $(variableName)

See the screenshot below for reference:

Create the versioning for the build

For tracking the build, versioning is important and TFS has the option for creating a Build number format.

For the Build Definition, navigate to the General section and provide the Build Number Format based on the project need.

$(BuildMajorVersion).$(BuildMinorVersion).$(BuildNumber)$(rev:.r)
Rev.r is increment every time when the code is merged.

The build number after this specific definition is 1.0.0.30, 1.0.0.31 and so on.

Agent Queue

Agent Queues manages the list of agents configured and the request capabilities for the build agent.

Build Summary

Click on the Build definition created and a complete summary of the build definition can be viewed.

Summary contains the recently completed builds details, edit options for the build definition, queue the new build option and history for the build definition.

Set up the test assemblies for running the tests

Add the test assembly for test execution with the builds.

 

Build definition execution

Whenever a code check-in is done, the build starts and all the steps are executed in specified order.

 

Navigate to the Tests Tab for the TFS and go to the Runs section, here the complete Automated tests execution results can be viewed. All the details for the build platform, environment can be viewed here and the .trx file for the current build execution can be downloaded from this section and this .trx file contains the complete execution details of the tests triggered along with the build with the Pass/Fail status , failure reason.

 

In the next post we will discuss about how to Set up the Continuous Deployment using TFS.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply