Git SCM, Gerrit Review tool and Jenkins/Hudson Continuous Integration Servers:

1. Min Hardware’s
a. 2 GB’s RAM
b. 5 GB’s Disk
2. Operating System Linux/Cent OS with latest update
a. Root or SUDO access
b. SSH service
c. Internet connectivity (need to download required software)
d. SMTP or Email server configuration
e. Open Port’s 29418, 8080, 8888
f. Users setups jenkins, demo and any others if required
3. Java JDK 1.7.x
4. Git installer or RPM
5. Gerrit 2.2.x WAR
6. Database H2, PostgreSQL and MySQL
7. Jenkins/Hudson

Details descriptions:
1. How to check the RAM
    Logging with root/sudo user and perform the below command
    [root@localhost ~]# free –g
2. How to check the free desk space
    Logging with root/sudo user and perform the below command
    [root@localhost ~]# df -h
3. How to verify ssh
    Type the below command
    [root@localhost ~]# ssh
    usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-e escape_char] [-F configfile]
           [-I pkcs11] [-i identity_file]
           [-L [bind_address:]port:host:hostport]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [-W host:port] [-w local_tun[:remote_tun]]
           [user@]hostname [command]

4. How to check the Internet connectivity
   Type the below command
   [root@localhost ~]# wget
   You will get status code ... 200 OK
   It’s indicate that you have internet connectivity        
5. How to verify the SMTP
   Type the below command
   [root@localhost ~]# mail -f /var/spool/mail/root
6. How to add group/user
   Type the below command
   groupadd -g 1001 demo
   useradd -d /home/demo -g 1001 -s /bin/bash demo
   Reset the password
   Type the command
   [root@localhost ~]# passwd demo
   Changing password for user demo.
   New password:
   Retype new password:
   passwd: all authentication tokens updated successfully.

7. Java: Install java with yum command or Download & untar java files in local directory
   Note: If you have already java installed then avoid below steps. 
   yum install "java-1.7.0-openjdk"
   wget --no-cookies --no-check-certificate --header "Cookie:; oraclelicense=accept-securebackup-cookie" "   pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz"
   tar -xzvf jdk-7u79-linux-x64.tar.gz -C /home/
   Java Home/Path setting: 
   echo 'export JAVA_HOME=/home/jdk1.7.0_79' > /etc/profile.d/
   echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile.d/
   source /etc/profile.d/
   java -version
8. GIT
   Logging with root or SUDO user and perform the below command
   [root@localhost ~]#yum install git
   Refer from
   [root@localhost ~]# git --version
   git version 1.7.1
   [root@localhost ~]#git config --list
   [root@localhost ~]#git config --global "Vinod"
   [root@localhost ~]#git config --global ""
   [root@localhost ~]#git config --list
   [root@localhost ~]#mkdir gitrepo
   [root@localhost ~]#cd gitrepo/
   [root@localhost ~]#chmod –R 777 gitrepo

   [root@localhost ~]#git init --bare /home/gitrepo/tutorialbyexample
   Note: Blank tutorialbyexample repository created.
9. Gerrit: Installed the Gerrit by downloading the gerrit-2.10.4.war file
   Logging with root/sudo user
   [root@localhost ~]mkdir gerrit
   [root@localhost ~]chmod 775 gerrit
   [root@localhost ~]cd gerrit
   [root@localhost ~]#wget "" -o /home/gerrit/gerrit-2.10.4.war
   [root@localhost gerrit]#java -jar gerrit-2.10.4.war init -d /home/gerrit
   Answer the various questions, such as:
   Location of Git repositories [git]
   Import existing repositories [Y/n]
   Database server type [H2/?]
   Authentication method [OPENID/?]
   type ? and then choose development_become_any_account or type development_become_any_account
   SMTP server hostname [localhost]
   SMTP server port [(default)]
   SMTP encryption [NONE/?]
   SMTP username
   Run as [you]
   Java runtime [/home/jdk1.7.0_79/jre]
   Copy gerrit.war to /home/gerrit/bin/gerrit.war [Y/n]
   Listen on address [*]
   Listen on port [29418]
   Download and install Bouncy Castle [Y/n]
   Behind http reverse proxy [y/N]
   Use SSL [y/N]
   Listen on address [*]
   Listen on port [8888]
   [root@localhost gerrit]# ./bin/ stop
   [root@localhost gerrit]#java -jar gerrit-2.10.4.war reindex
   [root@localhost gerrit]# ./bin/ start
   [root@localhost gerrit]#wget http://localhost:8888/

   Fixing the email address issue:
   [root@localhost gerrit]# bin/ stop
   Stopping Gerrit Code Review: OK
   [root@localhost gerrit]# ls -tlr
   total 40796
   -rwxrwxrwx 1 root root 41726206 May  7 12:19 gerrit-2.10.4.war
   drwxrwxrwx 2 root root     4096 May 20 11:59 static
   drwxrwxrwx 2 root root     4096 May 20 11:59 plugins
   drwxrwxrwx 2 root root     4096 May 20 11:59 lib
   drwxrwxrwx 2 root root     4096 May 20 11:59 data
   drwxrwxrwx 2 root root     4096 May 20 12:02 tmp
   drwxrwxrwx 2 root root     4096 May 20 12:02 bin
   drwxrwxrwx 3 root root     4096 May 20 12:08 index
   drwxrwxrwx 3 root root     4096 May 27 17:06 etc
   drwxrwxrwx 2 root root     4096 May 27 18:15 cache
   drwxrwxrwx 2 root root     4096 May 27 18:15 db
   drwxrwxrwx 2 root root     4096 May 27 18:15 logs
   [root@localhost gerrit]# java -jar bin/gerrit.war gsql
   [2015-05-27 18:15:57,656] INFO : Defaulting core.streamFileThreshold to 58m
   Welcome to Gerrit Code Review 2.10.4
   (H2 1.3.174 (2013-10-19))

   Type '\h' for help.  Type '\r' to clear the buffer.

   gerrit> select * from ACCOUNT_EXTERNAL_IDS;
   1000000    | | NULL     | uuid:70ca83b5-6797-4e3c-a959-b7a22de78fa0
   1000000    | | NULL     |
   1000000    | | NULL     | username:extvkx
   (3 rows; 4 ms)
   gerrit> update ACCOUNT_EXTERNAL_IDS set EMAIL_ADDRESS='' where ACCOUNT_ID=1000000;
   UPDATE 2;UPDATE 3; 10 ms
   [root@localhost gerrit]#  bin/ start
   Starting Gerrit Code Review:
   User configuration for mapping to git and gerrit:
   Logging with demo user
   Type the command
   [demo@localhost ~]$ ssh-keygen -t rsa -b 2048
   Generating public/private rsa key pair.
   Enter file in which to save the key (/home/demo/.ssh/id_rsa):
   /home/demo/.ssh/id_rsa already exists.
   Overwrite (y/n)? y
   Enter passphrase (empty for no passphrase):
   Enter same passphrase again:
   Your identification has been saved in /home/demo/.ssh/id_rsa.
   Your public key has been saved in /home/demo/.ssh/
   The key fingerprint is:
   bf:bc:9a:58:1f:0a:2b:3c:d1:4a:ef:8f:95:14:f7:24 demo@localhost.localdomain
   The key's randomart image is:
   +--[ RSA 2048]----+
   |                 |
   |                 |
   |        . E .    |
   |         o +     |
   |     .  S   .    |
   |    o .. o       |
   |   o +. + o      |
   |    = .B = o     |
   |     +=.=.=.     |
   [demo@localhost ~]$ vi .ssh/
   Copy the content and pest in gerrit SSH Public keys 

   Click on the Become link located in right top corner
   Click on the new account


   Click on the Add button
   And Continue

   Verification, just type the below command:

   [demo@localhost ~]$ ssh -p 29418 demo@localhost
   ****    Welcome to Gerrit Code Review    ****
   Hi demo, you have successfully connected over SSH.
   Unfortunately, interactive shells are disabled.
   To clone a hosted Git repository, use:
   git clone ssh://demo@localhost.localdomain:29418/REPOSITORY_NAME.git
   Connection to localhost closed.

   Cloning the git reposetory: tutorialbyexample
   [demo@localhost ~]$ git clone ssh://demo@localhost:29418/tutorialbyexample
   Initialized empty Git repository in /home/demo/tutorialbyexample/.git/
   warning: remote HEAD refers to nonexistent ref, unable to checkout. cd tutorialbyexample 
   [demo@localhost ~]$ cd tutorialbyexample/
   [demo@localhost tutorialbyexample]$ cd .git/hooks
   [demo@localhost hooks]$ scp -P 29418 demo@localhost:hooks/commit-msg .
   commit-msg             100% 4362     4.3KB/s   00:00
   [demo@localhost hooks]$ cd ../..
   [demo@localhost tutorialbyexample]$ git config remote.origin.push refs/heads/*:refs/for/*
   [demo@localhost tutorialbyexample]$vi
   public class MainApp{
   public static void main(String a[])
     System.out.println("Git, Gerrit, Jenkins and Java");
   [demo@localhost tutorialbyexample]$git add
   [demo@localhost tutorialbyexample]$ git commit -m " New added for testing the Git, Gerrit, Jenkins and Java"
   [master (root-commit) da284c6]  New added for testing the Git, Gerrit, Jenkins and Java
    1 files changed, 6 insertions(+), 0 deletions(-)
    create mode 100644
[demo@localhost tutorialbyexample]$ git push origin
   Counting objects: 3, done.
   Delta compression using up to 2 threads.
   Compressing objects: 100% (2/2), done.
   Writing objects: 100% (3/3), 397 bytes, done.
   Total 3 (delta 0), reused 0 (delta 0)
   remote: Processing changes: new: 1, refs: 1, done
   remote: New Changes:
   remote:   http://localhost.localdomain:8888/4  New added for testing the Git, Gerrit, Jenkins and Java
   To ssh://demo@localhost:29418/tutorialbyexample
   * [new branch]      master -> refs/for/master 

10. Jenkins/Hudson:
   Logging with root/sudo user
   [root@localhost home]#sudo wget -O /etc/yum.repos.d/jenkins.repo \
   [root@localhost home]#sudo rpm --import
   [root@localhost home]#sudo yum install jenkins
   Jenkins file will there in belwo directory:
   [root@localhost home]#sudo service jenkins start

jenkins user will crated by default
[root@localhost home]#sudo su -s /bin/bash jenkins
[root@localhost home]#git ls-remote -h ssh://jenkins@localhost:29418/tutorialbyexample HEAD
Follow the user setup like demo above for gerrit and git for Jenkins user as well for fingerprint.
Download the Jenkins.war file from
[root@localhost home]# mkdir jenkins
[root@localhost home]#chmod –R 777 jenkins
[root@localhost home]#java -jar jenkins.war

Create the Jenkins job:
Follow the following steps:
1. Click on the 'New Job' at the top left. It will ask for a Project name: git-gerrit-jenkins-java-tutorialbyexample 
2. Under Source Code Management Select Git as the SCM type (if it's not shown, it means that you need to install the Git plugin above). The Repository URL will be     ssh://jenkins@localhost:29418/tutorialbyexample and Branch Specifier (blank for 'any'): */master
3. Build Triggers: Select the Poll SCM and endter the Schedule: * * * * *  This is a crontab-like format, which in this case equates to checking the repository every  minute.
4. Scroll down to add a build step and Build Command: pwd
   javac *.java
   java MainApp
5. Finally, click on Save and the project should be created.
Create the directory git-gerrit-jenkins-java-tutorialbyexample under /var/lib/jenkins/jobs
And place the config.xml file under git-gerrit-jenkins-java-tutorialbyexample

<?xml version='1.0' encoding='UTF-8'?>
  <scm class="hudson.plugins.git.GitSCM" plugin="git@2.3.5">
    <submoduleCfg class="list"/>
      <spec>* * * * *</spec>
javac *.java
java MainApp</command>
    <hudson.tasks.Mailer plugin="mailer@1.11">

Jenkins > Gerrit Triggers:
Open the http://localhost:8080/
Click on the Jenkins
Click on the Manage Jenkins
Click on the Gerrit Trigger

Click on the Add new server
Enter the Add New Server: gerrit-localhost
Click on the OK

or add /var/lib/jenkins/gerrit-trigger.xml file:
<?xml version='1.0' encoding='UTF-8'?>
<com.sonyericsson.hudson.plugins.gerrit.trigger.PluginImpl plugin="gerrit-trigger@2.13.0">
  <servers class="java.util.concurrent.CopyOnWriteArrayList">
      <config class="com.sonyericsson.hudson.plugins.gerrit.trigger.config.Config">
        <gerritVerifiedCmdBuildSuccessful>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;Build Successful &lt;BUILDS_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildSuccessful>
        <gerritVerifiedCmdBuildUnstable>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;Build Unstable &lt;BUILDS_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildUnstable>
        <gerritVerifiedCmdBuildFailed>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;Build Failed &lt;BUILDS_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildFailed>
        <gerritVerifiedCmdBuildStarted>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;Build Started &lt;BUILDURL&gt; &lt;STARTED_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildStarted>
        <gerritVerifiedCmdBuildNotBuilt>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;No Builds Executed &lt;BUILDS_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildNotBuilt>
        <categories class="linked-list">
            <verdictDescription>Code Review</verdictDescription>
          <slaves class="linked-list"/>
          <timesOfDay class="linked-list"/>

Note: /var/lib/jenkins/.ssh/id_rsa has been generated at the time of ssh-keytool for jenkins user.

Create new Jankins Jobs:

Click on the Jenkins
New Item
Enter the Item name:git-gerrit-jenkins-java-tutorialbyexample
Click on the Ok.

config.xml file:
<?xml version='1.0' encoding='UTF-8'?>
  <scm class="hudson.plugins.git.GitSCM" plugin="git@2.3.5">
    <submoduleCfg class="list"/>
        <buildChooser class="com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTriggerBuildChooser" plugin="gerrit-trigger@2.13.0">

    <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger plugin="gerrit-trigger@2.13.0">

It's done for now try it from your end and put your point if any.



  1. Git SCM, Gerrit Review tool and Jenkins/Hudson work for me ..... good for all stuff in single more on git...

    1. Thanks for your valuable feedback on Git SCM, Gerrit Review tool and Jenkins/Hudson Continuous ...


Please provide your input, it will honer for me...