VRealize Code Stream – vRCS 1.0 – Laying the foundation with Git and Jenkins Part 1

Caution: Articles written for technical not grammatical accuracy, If poor grammar offends you proceed with caution ;-)

I realize many of you looking to understand what Code Stream can do to help you with your Continuous Integration needs already have Git Jenkins and a whole ton of other tools. However for those who don’t yet have anything in place or for those who are looking to get a better understanding of where it fits into the mix I am going to walk through some simple setup examples to get you up and going.  To start we need to have two foundational elements in place; Git and Jenkins.

As part of the Git setup I’m going to help you get Git in place and tie your IDE (Eclipse) into Git for publishing code check-ins to your repository.  Then we will deploy a Jenkins server and integrate both Git with Jenkins to create simple builds that we can use with Code Stream.

What we need to get started

To begin we will need to have two servers deployed in the environment.  The first will be got Git and the second for Jenkins.  In my lab I deployed Centos 6.3 because I already had a template available.  I would recommend you have these deployed and ready.


Deploying a Git Server

I choose to use GitLab community edition for my Git server.  It seemed to offer the most options and flexibility for the lab.  The gitlab community edition is available at https://about.gitlab.com/downloads/.

Once you choose the version that appropriate for your OS version the installation is pretty simple.  Gitlab provides you with basic installation steps which as pretty straight forward.  Those installation steps for Centos 6 are:

Install Dependencies

sudo yum install openssh-server
sudo yum install postfix
sudo yum install cronie
sudo service postfix start
sudo chkconfig postfix on
sudo lokkit -s http -s ssh

Download and Install Omnibus package

curl -O https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-7.7.2_omnibus.5.4.2.ci-1.el6.x86_64.rpm
sudo rpm -i gitlab-7.7.2_omnibus.5.4.2.ci-1.el6.x86_64.rpm


Configure and start GitLab Server

sudo gitlab-ctl reconfigure


Connect to Gitlab server and login

Navigate to your Gitlab server in your browser by IP or hostname on port 80 and login using:

Username: root

Password: 5iveLife

When you login you will need to change the password and if you like you can go ahead and create other accounts for use on the gitlab server.

Deploying a Jenkins Server

Jenkins much like Git is simple to install.  You can find the instructions at https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions.  I will provide a basic run down below, but I recommend looking at the Jenkins page as there is some additional good info there.


Add the Jenkins repository to the yum repos, and install Jenkins from here.

sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm –import https://jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins

Installation of a stable version

There is also a LTS YUM repository for LTS Release Line

sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
sudo rpm –import http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
sudo yum install jenkins

Install of Java

Jenkins requires Java in order to run, yet certain Fedora-based distros don’t include this by default. To install the Open Java Development Kit (OpenJDK) run the following:

sudo yum install java

Note: If running CentOS, ensure you follow the guide below.

sudo service jenkins start/stop/restart
sudo chkconfig jenkins on


Configuring  the GitLab Server

Next it’s important to get a project setup in our GitLab server that we can use throughout the rest of our examples.  Your project can be anything that you want it to be.  I’m going to use this blog as my project.  I am going to load all the source php files for dailyhypervisor which is based on WordPress. We will then configure eclipse to use the git repo as a source repository.

1. Login to your Gitlab server and create a new project by selecting Project in the upper right corner.


2. On the new project screen set a “Project path” which for all intensive purposes can just be a name for the project.  Set the namespace which for my project I choose my namespace, set a description and then the visibility level.  I have chosen public for my visibility level for no other reason than laziness.  I have done this so i don’t have to spend the time setting up the authentication and SSh keys and all that goes with it.  You can certainly do so if you like and use internal or private. (Remember this is a private server in my lab so I’m not concerned about access to the repository.)


3. Once you create the project you will be brought to a page that has information about your new project.  At the top of the page below “New Service” you will see the connection url for the project.  You can get either the SSH or HTTP connection url.  (You may notice that my connection URL show “SomeNewService.git” and not “dailyhypervisor.git” and that is because this screenshot was an example I took after I created the dailyhypervisor project.  Your url should have the name of your project path.)


4. The next thing we want to do is connect eclipse to the git repository.  I found a pretty decent video on you tube that walks through getting eclipse setup for use with git.  Use this video to get your eclipse ide setup for git and I will walk through how to adda new project to eclipse and set it up for git below.  (Note I’m not going to walk through how to enable git support in eclipse you will need to watch the video for that portion.)  The video is available at https://www.youtube.com/watch?v=r5C6yXNaSGo.

5. In eclipse go to File –> New –> Project.  When the dialog appears select General –> Project and click next.


6. On the next screen give your project a name and click finish.


7. Now that we have a new project in eclipse we need to add some content to the project.  For me I simply opened up the folder in finder where I had downloaded the dailyhypervisor files to and did a drag and drop from finder in to the project in the eclipse UI.


8. Next Right click on the project got to Team –> Share Project.


9.  Select Git and click next


10. Select Create to create a new repository.


11. Input a path for the local repository and click finish.


12.  Click finish again.  Once you click finish eclipse will move your files in your project to this new location.


13. Notice in PHP Explorer that the project now has the local Repo name with NO-HEAD after it.  This is because we still need to connect the project to the Git repository.


14.  Now right click on the project go to Team –> Commit to commit the changes to the new repository.


15. Enter a Message then select the files you would like to commit.  I selected the select all check box to commit everything.  Then click commit.


16. In the Git Repositories pane expand your project.  You will see a item called Remotes.  Right click on remotes and select Create Remotes


17. Leave the defaults and select OK


18. Select Change


19. Paste in your http uri from gitlab.  It will auto-populate most of the fields for you.  Just input your gitlab username and password and click finish.


20. Next Select Advanced.


21. Select Master from the Source ref: drop down and then select “Add Spec” button, then click finish.


22. Select “Save ad Push”


23. You will then see eclipse push the project file to the git project.


24. If you go back to our GitLab server and look at the project we will see the push.


25.  We now need to configure the fetch.  In the Git Repositories pane navigate to your_project –> Remotes –> Origin –> and right clock on the entry with the green arrow and select Configure fetch.


26. Select Advanced


27. Select master from the Source ref drop down, clik Add Spec and click finish.


28. Finally click Save and Fetch.



Now that eclipse is setup to use your GitLab repository you can edit code and check it in as well as pull down code that may have been updated from someone or someone else.  Just remember when you update a file first save it, the do a commit and push.  You can do it as one action or two separate actions.  Doing COmmit will commit the changes to your local repository and push will send it to the git server.  There is a lot more to know about source control with git and it’s outside the scope of this article, but this should get you started.

Check back for Part 2 where we will be connecting Jenkins to the Git repository and performing a basic build of the project.

Leave a Reply