Jenkins Git Integration on Ubuntu

In this article, we will install Jenkins on Ubuntu and examine the following items:

  • Developer commits to source code management system.
  • Jenkins job will be notified.
  • Jenkins send a pull request to GitHub.

Configuration of Jenkins on Ubuntu

First, we have to add the key and source list to apt. Apply, below two commands in order.

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -
echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list

Now we need to update Ubuntu.

apt-get update

We need to install Jenkins now. Be aware it takes some time to install Jenkins.

apt-get install jenkins

The default port number for Jenkins is 8080. The below screenshot is the entry page or Dashboard of Jenkins.

2016-03-12_23-18-15

Restart Jenkins with this command: http://localhost:8080/restart

2016-03-12_23-44-52

We need git in our system so we will install it with the below command.

sudo apt-get install git

Congratulations, Jenkins’s environment setup has been completed. :)

Integrate Jenkins and GitHub

In this tutorial, we will use GitHub as a source code repository. We need to install the Jenkins GitHub plugin, for more information visit https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin .

Manage Jenkins page, select Manage Plugins on the available tab search box  = GitHub

2016-03-12_23-39-04

2016-03-12_23-40-18

The above figure shows that GitHub API Plugin has successfully installed to the system.

We will configure Jenkins to trigger a build when a file is modified in the GitHub repository.

  • Connect to the Jenkins server again. Click the New Item link in the left navigation.
  • Name your build job, and choose the Freestyle project. Click OK.

2016-03-16_22-43-04

  • Copy the URL from your GitHub project.

2016-03-16_22-48-06

  • In order to manage Jenkins, we need to set executable.

2016-03-16_23-42-14

  • Create a new job and name it.

2016-03-17_16-42-58

  • Specify your GitHub project at source code management.

2016-03-17_16-47-56

  • Add credentials  Username / Password

2016-03-17_16-57-49

  • You can change the build trigger using the below options.

2016-03-17_16-59-55

  • If your job is triggered you should below result. It will finish with SUCCESS! :)

2016-03-17_17-15-38

Thanks.
Onur Yazir

2 thoughts on “Jenkins Git Integration on Ubuntu”

  1. I think you’ll like it better in a multi-platform and multi-version git world if you define the git executable as “git” rather than as “/usr/bin/git”. The /usr/bin/git path does not work well on the default Windows git configurations, while “git” can work well in at least two different Windows configurations.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.