Pages

Monday, December 28, 2015

Maven with GIT

In this article we will see how we can configure git with Maven. For this we need to create a Git Repository and then create a maven based application on this. The same thing can be further used in Jenkins with Git Configuration.

The important thing to remember here is when you run the maven command make sure you create a directory with the application name and in side initialize the git and run the maven command in there. Create a directory sampleTest and inside that directory follow the steps,

1) run the maven sample web application command as

mvn archetype:generate -DgroupId=com.git.testing -DartifactId=SampleTest -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

2) Check the Status and we will see that we have a CounterWebApp application created.

[root@vx111a testing]# git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       CounterWebApp/
nothing added to commit but untracked files present (use "git add" to track)


[root@vx111a testing]# ll
total 0
drwxr-xr-x. 3 root root 30 Dec  3 14:47 CounterWebApp

Add and Commit
[root@vx111a testing]# git add .
[root@vx111a testing]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#       new file:   CounterWebApp/pom.xml
#       new file:   CounterWebApp/src/main/webapp/WEB-INF/web.xml
#       new file:   CounterWebApp/src/main/webapp/index.jsp
#
[root@vx111a testing]# git commit -m "Jenkins Testing with Local Repo"
[master (root-commit) 551c28c] Jenkins Testing with Local Repo
 3 files changed, 33 insertions(+)
 create mode 100644 CounterWebApp/pom.xml
 create mode 100644 CounterWebApp/src/main/webapp/WEB-INF/web.xml
 create mode 100644 CounterWebApp/src/main/webapp/index.jsp

Check the Status again which is clean
[root@vx111a testing]# git status
# On branch master
nothing to commit, working directory clean

Note – Make sure you add the <plugins> information in the pom.xml file if you want the web app to be packaged.


More to Come.

1 comment :