sitelink1 https://www.softwaretestinghelp.com/tfs-...se-devops/ 
sitelink2  
sitelink3  

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.

Using-Microsoft-TFS-2015-Update-3-for-Java-Projects-Build-Test-and-Deploy1.jpg

 

 

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

Prerequisite

  • 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

00Install-New-Software.jpg

 

 

Click here to Update site to install the plugin.

(Note: Click on any image for enlarged view)

01install-the-plugin-768x601.jpg

 

 

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

02Team-Explorer.jpg

Team Explorer1

 

 

Click on Connect to Team Services or a Team Foundation Server

Connect to Team Services

Team Foundation Server

Team Foundation Server1

My TFS project

My TFS project1

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

a J2EE Maven Project in Eclipse

share the project

Team Foundation Server11

Connect

My TFS project11

TFS Workspace

Hello Maven Web

Confirmation

Confirmation1

First time Check-in to TFS VC

First time Check-in

Confirm check in

sccessfully checked in

hello world

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

J2EE web project

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.

traceability

traceability

pending changes

source files

Select the Work Item and then click Check-in

work items

eclise1

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

links tab

webapp

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.

new build definition

new build definition1

 

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’

Maven

Maven1

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

generic

generic connection

Click Ok

click ok

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

SonarQube

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

Copy 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

http://{your_server}:8080/tfs/_admin/_AgentPool

Click on Download agent as a ZIP file.

Download agent

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

ConfigureAgent.cmd

install the agent

Enter details as asked for

Enter details

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

Install

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

Save Changes

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.

download

manage extension1

Click on Install, to install the extension to the Collection

install the extension

install the extension1

install the extension 2

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.

Tomcat

Create the Release

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

Release Tab

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

Link 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

Click on the Link

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

Configure the Deployment

Deployment conditions

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

Add Tasks

Add Tasks1

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.

Triggers

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.

Automated Build and Deployment

Build Results

Build Results

SonarQube Code Analysis Results

SonarQube Code Analysis Results

Deployment to Tomcat

Deployment to Tomcat

Conclusion

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.

 
번호 제목 글쓴이 날짜 조회 수
76 [code review response] 코드 검토 응답을 실수한 경우 응답 제거 방법 file 황제낙엽 2020.02.03 260
75 TFS Requirements (required env spec) 황제낙엽 2020.01.31 267
74 WorkItem 의 System.History 필드 조회 불가 황제낙엽 2020.01.16 233
73 Sharepoint Server 황제낙엽 2020.01.13 260
72 TF401256: You do not have Write permissions for query Shared Queries. file 황제낙엽 2019.12.17 4389
71 다른 프로젝트의 WI를 조회하는 법 (Query across projects) file 황제낙엽 2019.12.02 360
70 Visual Studio Team Explorer Everywhere for Eclipse (Azure DevOps Services and TFS) file 황제낙엽 2019.12.02 525
» TFS 와 Eclipse 연동 (Visual Studio TEE Plugin for Eclipse) file 황제낙엽 2019.12.02 452
68 외부 구성원에게 팀프로젝트의 특정 브랜치에만 권한 부여하는 방법 황제낙엽 2019.05.24 275
67 팀프로젝트에 Reader 권한의 계정 추가 방법 황제낙엽 2019.01.29 350
66 Adopting Team Explorer Everywhere (TFS-SDK 최신버전 다운로드 가능) file 황제낙엽 2018.12.08 336
65 Microsoft Volume Licensing Service Center 관리자 권한 관련 file 황제낙엽 2018.09.06 301
64 TFS 에서 Workspace 삭제 (TF.exe) 황제낙엽 2018.06.04 488
63 [WORKITEMTYPE] 다른 Field 의 value 값에 따라 동적으로 속성 변경하기 - <WHEN> 황제낙엽 2018.01.26 237
62 [witadmin] 모든 FIELD XML Element (API References) 황제낙엽 2018.01.24 251
61 Process Template Editor for Team Foundation Server 2017 file 황제낙엽 2017.10.31 636
60 Power Tools for VisualStudio file 황제낙엽 2017.10.31 262
59 Visual Studio 2017 에서 TFS 에 접속시의 에러 (TF30063: You are not authorized to access) 황제낙엽 2017.09.26 741
58 [TFS SDK for Java] WorkItem 필드값 수정 예제 황제낙엽 2017.09.21 298
57 MSDN 라이선스 기술지원을 위한 Access ID 발급 방법 황제낙엽 2017.09.11 264