Monday, July 13, 2015

TFS Java Projects with MS Build and Release Management (TFS End To End ALM for Java Project)




Setup Java environment for TFS Build
Download the Dump software’s which we can un zip and make use of it no need of installation.

1.       Download Apache Ant from below link
2.       Download Java JDK from below link
3.       Download Apache tomcat from below link
4.       Download TFS build Extension from below link
5.       Download eclipse from below link
http://eclipse.org/downloads/
6.   Download Horizons java project from below link
http://templated.co/horizons/

Steps for Setup
1.       Un zip the apache ant folder and copy to C drive


2.       Un zip the apache tomcat folder and copy to C drive or if it is exe file install it



3.       Un zip the java folder and copy to C drive or if it is exe install it



4.      Go to “My Computer” Right click and select “Properties
5.      Click on “Advance System Settings






6.      Go to “Advance Tab” and the click on “Environment Variables” 

7.      Under “system variables” section click on “New

8.      Set the Environment variables for Ant, Java, Apache Tomcat
For ant give the variables and click on ok

Again click on new For java give the variables and click on ok

Again click on new For Tomcat give the variables and click on ok

9.       Now go to “path variable” and click on edit

Append the variables at the end of the “path variable” like
Note: give the “; “ properly in variable values.
%JAVA_HOME%\bin;JAVA_HOME%\lib;%ANT_HOME%\bin;%ANT_HOME%\lib;%CATALINA_HOME%\bin;%CATALINA_HOME%\lib;




10.   For apache tomcat change the port number
Open server.xml file “C:\apache-tomcat-7.0.55\conf\server.xml”

Now I am changing the port 8080 to 6767 and save it

11.   Now enable the users
Open tomcat-users.xml “C:\apache-tomcat-7.0.55\conf\tomcat-users.xml”

Now remove the comment surrounded the roles and user tag(<!-- -->)
And add two lines highlighted and save it

12.   Now start the tomcat and check it working
Got to the path “C:\apache-tomcat-7.0.55\bin”
Right click on statup.bat and click on “Run as Administrator”

Then tomcat will start you will see the CMD screen like this


13.   Now go and launch browser with this URL http://localhost:6767
             



14.   Click on Manage App it will prompt the windows security window then give the credentials (the credentials which you given in this file “tomcat-users.xml” where you add two line in it).





After click on ok you will see the projects list screen which are in tomcat server.
 




15.   Now install the TFS build Extension on build server




Click on next





Select “I Agree” and click on next

Click on next




Click on next

Installation is completed click on close.
 




16.   Setup project in eclipse
Note:(If it is existing eclipse project goto file->import->select “existing project to work space” Give the path of the project and click on finish)
Open eclipse
     


It will prompt for work space give any path and click on ok
Now go to file->new->dynamic web project

Give the project name and click on next



Click on next

Check the option Generate web.xml and click on finish


You will see the project

Open the “Horizons project” which you downloaded from above link copy all the content in it

Past it in the eclipse project which you created horizons->webcontent (under web content folder past the files)


Generate the build.xml file using export option
Right click on  project click on export

Select ant and click on next

Select the project and click on finish

You will see the build.xml file in project

17.   Install Team explore every where
1.       Open Eclipse.
2.       On the Help menu, choose Install New Software.
The Install dialog box appears.

The install wizard looks slightly different for different versions of Eclipse.
3.       Choose Add.
The Add Repository dialog box appears.

4.       In Name, enter TFS Plugin for Eclipse.
5.       In Location, enter http://dl.microsoft.com/eclipse/tfs, and then choose OK.
6.       In the list of features in the Install dialog box, select the check box that corresponds to Team Explorer Everywhere, and then choose Next two times.
Note: uncheck Contact all update sites during install to find required software 

7.     Accept the Microsoft Software License Terms, and then choose Finish.

8.     Restart Eclipse when prompted click on restart.


18.   Open team explore everywhere.
       Window ->show view ->other


And select Team explorer click on ok

After team explorer window will open add the TFS server
     



19.   Share the project which is created in the eclipse

Select the team foundation server and click next

Select the team project to share the web project and click next

Click on finish



After finishing the sharing go to team explore -> pending changes
We can see the pending changes of the project shared click on check-in

It will ask for conformation to check in click on yes

We can see the changeset created



20.   Go to build and create the new build definition

Give the name of the build



In trigger select manual build 
In source settings give the TFS path for the project

In build defaults



In project File click on create(here we can see the warning)

Select the ant click on next

We generated build.xml in previous steps
Select the build.xml and click on next

Here in drop down select default which will take the version of the java and ant we configured
Note: (if we want to run this project on different versions in drop down select the source control refer the link "http://msdnsolutions.blogspot.in/2015/07/java-to-build-in-different-versions.html”)
Click on finish

After finishing warning will be gone it will create a .TFSproj file in version control you can check it.
Click on ok

21.   Now trigger the build

 Click on queue

You can see the build has been passed

22.   For release management use the template we provided
Add the ReleaseUpgradeTemplate.xaml to that team project and check in it.
(download build template form here ReleaseUpgradeTemplate.xml)

Goto team explore in visual studio -> builds
Select the horizonss build which we created
Right click and select edit build definition

Goto process click on new

Select the template which we checked-in

Now select the template which we add from drop down
In Release Build option select “True”
In configurations to Release select “Any CPU and Release” And save the build

Now goto release management client create a release path.

Create components

In deployment from drop down select xcopy Deployer and then click on save

Now go to release templates double click on template created now

On components right click and add the component we created

Drag and drop the server where the tomcat is there in my case VSALM server

Drag and drop the copy file or folders for back up the existing content in tomcat server
Note create a folder in tomcat install path -> webapps -> create a folders horizons and horizons backup (source=horizons, destination= horizons backup)

Drag and drop component we created
And give the path of Horizons which is created in above step
Now go to the Property and linked the build

Drag and drop roll back activity and then inside this activity drag and drop the copy file or folders (source= horizon backup, destination = horizons)



Now go to eclipse modify the index.html page and save the file and go to pending changes and check in.

Now trigger the build
Go and check in RM client the project has been released

Now go to browser URL http://localhost:6767/
And click on manage app and then you can see the projects list
Here we can see the projects horizons and horizons backup
Click on horizons

Here we can see the change which we modified in index.html file



2 comments: