CI for a Maven+Git project

How to create a continuous integration pipe for any maven+git application ?

My last goal was to create and install a full working pipe of Continue Integration for my Java « mavenized » and « gitified » projects.

Using our good old pals Jenkins and Sonar, with my older pal ubuntu in a VM, we were able to create a « Ready to use Integration machine ».

So… action !

First Step  : VM and Ubuntu

1. Get VirtualBox

sudo apt-get install virtualbox

2. Download ISO image of Ubuntu Server

download the 32bits ISO image from

3. Create a new VM to install the downloaded ISO

set 1GBytes of memory, to start a small project this must met just right.

create a new user with jenkins/jenkins as user/password with an administrator profile.

Second Step : Java plateform

Login to your brand new virtual server and follow the next lines.

1. Install Java 6

sudo apt-get install openjdk-6-jdk

Verify good installation with the followinf command line

mcg/linux$ java -version

You must get the log bellow :

java version "1.6.0_24" OpenJDK Runtime Environment (IcedTea6 1.11.4) (6b24-1.11.4-1ubuntu0.12.04.1) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

2. download Maven 3.0.4 from and unzip it in the /opt/tools/java/tools/maven/3.0.4 path

Set full access to folde :

chown 777 +R /opt/tools/java/tools/maven/

add maven to yout system path:

export M2_HOME=/opt/tools/java/tools/maven/3.0.4/ export PATH = $PATH;$M2_HOME;.

the verify installation with a :

mvn -v

You must obtain :

Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100) Maven home: /opt/tools/java/tools/maven Java version: 1.6.0_24, vendor: Sun Microsystems Inc. Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre Default locale: fr_FR, platform encoding: UTF-8 OS name: "linux", version: "3.2.0-31-generic", arch: "amd64", family: "unix"

Third Step : Jenkins and Sonar

1. Add the APT repository from

wget -q -O - | sudo apt-key add -

Add the following line to /etc/apt/sources.list

deb binary/

and the execute the following lines into a terminal:

sudo apt-get update sudo apt-get install jenkins

verify installation with your favorite browser and open the url http://localhost:8080/

2. Download Sonar from, get the last ZIP version (here is the 3.2.1)

unzip it into /opt/tools/sonar/3.2.1/, then change rights on the folder:

chown 777 +R /opt/tools/sonar/3.2.1/

and start Sonar with a

/opt/tools/sonar/3.2.1/bin/ start

Verify Sonar web access crowling the http://localhost:9000/ url.

Fourth Step: configuration

OK, then configure Jenkins to  accept JDK, Maven and Sonar with the right bundle of plugins; choose the following list of plugins:

  • git plugin, don’t forget to set the git command path to /usr/bin/git
  • sonar plugin, set the sonart path to /opt/tools/sonar/3.2.1
  • set the maven path to /opt/tools/java/tools/maven/3.0.4

Optionaly you can add :

  • github plugin to connect github to one of your projects
  • gith OAuth security login (optional) to authenticate your Continuous Integration Server users with Github users.

Start : Create a Job !

1. Named your project

2. Select your maven version (the just installed 3.0.4 version)

3. Set the git repository (e.g. 🙂

4. Activate Sonar in the optional post-build actions (just add Sonar as post action)

go back to the Jenkins home page and then press the magic Build button !


Done !

Ready to read build state and tests results ?


figure 1 – Jenkins displaying build results


figure 2 – Sonar displaying project analyses with the « Time Machine » view

Very usefull tricks

To perform good build and better results, it’s better to add some additional plugins to Jenkins.

Here is the list of Beautiful things:

  • OpenId is an authentication plugin to perform user authentication with an OpenID system. Easily you will be able to connect to Google Account with the specific openId option in the Jenkins administration/configuration panel, using the specific url like
  • GoogleCalendarPlugin will publish build results to a specific Google Calendar. Very useful to analyze build stability over the time. Configuration is really simple, just create a Google Calendar or get your already existing one, and from Parameters/general setting, get the XML private url and past it onto your Job configuration. Set authentication stuff and activate « All builds » options, that’s it !

Have fun !


Les commentaires sont fermés.

Créez un site Web ou un blog gratuitement sur

Retour en haut ↑

%d blogueurs aiment cette page :