How to Use Microsoft TFS for JAVA Projects with Eclipse in DevOps

Using Microsoft TFS 2015 Update-3 for Java Projects (Build, Test and Deploy):

Nowadays, TFS is used for Java/J2EE projects integrated with Eclipse IDE. And with TFS 2015 Update 3, one can connect to any Team Foundation Server Git repo, using an SSH key.

Team Foundation Server (TFS) is an ALM product from Microsoft which provides the capabilities for an end to end development and testing using Work Item Management, Project Planning (Waterfall or Scrum), Version Control, Build/Release (Deploy) and Testing capabilities.

NOTE: This tutorial has many images so allow it to load properly.

Microsoft TFS For JAVA Projects With Eclipse In DevOps

Introduction to Microsoft TFS

TFS is tailored for Microsoft Visual Studio and Eclipse on all platforms, however, it can also be used as a back-end to several IDEs (Integrated Development Environments)

Though TFS is more widely used for .NET development using Visual Studio.NET IDE, it can also be used for Java/J2EE projects integrated with Eclipse IDE.

Now let us see the various activities performed once a TASK work item is raised in TFS

  • Link TASK work item to the Java code
  • Automated maven build
  • Code Analysis triggered using SonarQube
  • Deploy to Tomcat app server


  • Microsoft TFS 2015 Update 3
  • SonarQube 6.4 or above
  • Eclipse latest version (Luna used in this article)
  • JDK 1.8 and Maven 3.x installed on the build server. To configure JDK and install/configure Maven you can check the URL here: How to install Maven on Windows
  • Tomcat v7 or 8

Install the Visual Studio TEE Plugin for Eclipse

The Visual Studio TEE (Team Explorer Everywhere) plugin for Eclipse helps to connect to the TFS server and perform version control activities on the Java code.

Install the plugin to Eclipse using Help => Install New Software

1Install the plugin to Eclipse using Help

Click here to Update site to install the plugin.

(Note: Click on any image for enlarged view)

2Use the Update site install the plugin


Open the TFS Team Explorer to connect to the TFS server from Window => Show View => Other and select Team Explorer

5the TFS Team Explorer

7Team Explorer

Click on Connect to Team Services or a Team Foundation Server

9Team Foundation Server

10Team Foundation Server

11 Connect to Team Foundation Server

12 My tfs project

13Team Foundation Server

Create a J2EE Maven Project in Eclipse and share the project to TFS Version Control (VC)

15J2EE Maven Project in Eclipse and share the project to TFS Version Control (VC)

17share the project to TFS Version Control (VC)


21Connect to tfs

23share project to tfs

25tfs workspace

27share location

29 share the project to tfs

32 setting working folder

First time Check-in to TFS VC

33First time Check-in to TFS VC

35confirm checkin

37successfully checkedin


View of J2EE Maven Web project checked into TFS. Click on the CODE hub to look at the J2EE web project added to the repository


Traceability of Work Item with Source Code

One of the common issues often seen is that there is no traceability across lifecycle which leads to inconsistencies during development and delivery. So once a TASK/BUG is raised by PM it is simply kept at the back of mind and developed, which is not the right way of development.

Traceability helps to understand the status of artifacts across lthe ifecycle. To establish traceability change the source code, link to TASK/BUG work item and check-in.

43 checkedin

45 link to TASK work item and check-in

47 checkin source files

Select the Work Item and then click Check-in

49Select the Work Item and then click Check-in

51 successfully checkin

Open the Task Work Item and look at the links TAB to see the traceability established.

53Task Work Item

55links TAB to see the traceability established

Creating Build Definition with Code Analysis (SonarQube)

A build definition consists of series of Tasks which are executed during an automated build process. Example of tasks can consist of running a Maven/ANT build, MS Build, executing PowerShell or Shell scripts etc.

Some of the tasks, not available by default, are available as an extension which must be downloaded and installed into TFS.  Since we would be deploying a J2EE WAR file to tomcat, we would need to download and install this extension as a task. We will see this later in the next section

To create a Build Definition login to TFS web interface and go to Builds TAB. Click on + to create a build definition. Start with EMPTY definition and then click Next.

57Creating Build Definition

59Creating Build settings

Save the Build Definition and add the Maven build Step as shown below. Optionally if the artifacts need to be stored on the server, then add a build step ‘Copy and Publish Build Artifacts’

61add the Maven build

63Copy and Publish Build Artifacts

Select the POM file and add Maven Goal(S) such as   clean   install

Enable ‘Run SonarQubeAnalysis’. Click on Manage to provide the SonarQube URL and user id/password.

Click to create a Generic – New Service Endpoint which needs to be provided in the Maven Task

65create a Generic

67New Service Endpoint

Click Ok

69Save the Build Definition

Back in the Build Definition screen add this service endpoint to the SonarQube setting and then Save the Build Definition

71Save the Build Definition

Add ‘Copy and Publish Build Artifacts’ to store artifacts on server which will be used later in the Release Definition

73Copy and Publish Build Artifacts

This completes the Build Definition for the J2EE Web project, which includes running Code Analysis using SonarQube rules once the Build is completed. This process can be referred as Continuous Integration.

Installing an Agent

In order to Build and Deploy web applications, a windows agent should be downloaded and installed.

1) To download and install in TFS web go to the URL


Click on Download agent as a ZIP file.

75To download and install in TFS web go to the URL

2) Extract the agent ZIP file to a smaller folder like d:\tfsagent and then run the file as administrator to Install the agent


77install the agent

Enter details as asked for

79Enter details

3) Install similarly on the Deployment machine if different and Start the agent on Build and Deployment machine

81 Start the agent on Build and Deployment machine

4) The agent is listed. To this agent add a capability to look at the path of CURL utility. This needs to be installed on the DEPLOYMENT server for deploying to Tomcat. Then click on Save Changes

83CURL utility

To install VSO Agent for Linux see instructions to download from Deploy an agent on Linux

Creating a Release for Deployment

Now, let us look at the Continuous Deployment (CD) process which means that the automated deployment will begin once the Build is successful.

You will be able to see that, once the changes to the source code are checked-in the Automated Build, Deployment will run to all the environments defined.

1) Firstly as we would be deploying the WAR file to Tomcat app server, ensure to download and install the Tomcat extension deploy step from the Visual Studio marketplace.

2) After download, install it as per the instructions given.

85Started download

86manage extensions

Click on Install, to install the extension to the Collection

88install the extension to the Collection

90 Install, to install the extension to the Collection


Click Close. Now we can use the extension for automated deployment of WAR file to Tomcat app server.

Also, ensure Tomcat version 7 or 8 is installed on the deployment machine and if it is running or not.

94extension for automated deployment

Create the Release

Go to Release Tab and click on +. Start with empty release definition and add the Apache Tomcat deployment task.

96 add the Apache Tomcat deployment task

Save the release and rename the environment as QA. Click on the ‘Link to a build definition’

98Link to a build definition

Link the release definition to the build definition so that once the build is successful the deployment would be automatically called. No manual intervention is required here.

Click on the Link after selecting the Build Definition

100Click on the Link after selecting the Build Definition

Configure the Deployment Condition for the deployment to begin once the Build is successful and completed.

102Configure the Deployment Condition

104deployment condition

Add the Deploy Apache Tomcat step. Click on Add => Close

106Add the Deploy Apache Tomcat ste


Lastly, in the Triggers tab of the Release Definition select the radio button ‘Continuous Deployment’ with the Build Definition. This ensures that deployment would automatically be triggered once the build is successfully completed.

110Continuous Deployment

Save the Release Definition

Initiate the Automated Build and Deployment

Once a code change is done the Build and Deployment will be triggered automatically. Let’s do a change in the code and see the entire CI / CD process being automated. No manual intervention is required here.

112Initiate the Automated Build and Deployment

Build Results

114Build Results

SonarQube Code Analysis Results

116SonarQube Code Analysis Results

Deployment to Tomcat

118Deployment to Tomcat


Microsoft TFS can be used for Java projects in a DevOps scenario. The benefit that users can take from this is a completely automated build and deployment process to various environments (Dev, QA, Pre-Prod etc.) without any manual intervention and also hooks up with code analysis tools like SonarQube.

In my experience, I have seen several manual steps for the activities done above for which it takes months for the new features / change requests / bug fixes to be deployed from Dev to PROD environment. So ALM tools like Microsoft TFS helps to reduce the deployment cycle which helps organizations to deploy quality software faster.

So any organization who has already invested in Microsoft TFS licenses can use the tool for .NET and Java projects. Most importantly to use in a DevOps model.