Derek Kwok's Blog

Blog about Software Development, Techniques and Discoveries.

Jenkins and Github

| 5 Comments

In this post we are going to assume you are setting up Jenkins on Ubuntu Linux 10.10.

Installing Jenkins

Jenkins-CI can be installed on Ubuntu Linux through aptitude. I have outlined the key steps below. In your terminal type in the following commands:

This will install Jenkins onto your computer directly. The default url which you can access Jenkins is http://localhost:8080/ (so make sure you’re not running any other services in port 8080, e.g. Tomcat).

Navigate to http://localhost:8080/ and you will be greeted with the Jenkins dashboard.

Jenkins Dashboard

(Please note that you may not have a “Job” like in the screen shot above. To setup a job, click “New Job” in the top left corner of the dashboard)

Adding git Support in Jenkins

To add git support, navigate from the dashboard:

  • Manage Jenkins –> Plugin Manager –> Available

Find:

  • Jenkins GIT plugin”
  • Github plugin

Check both check boxes. Scroll to the bottom of the page and click “Install”.

Installed Plugins Page in Jenkins

If you have installed the Jenkins GIT plugin properly, you will see it in the “Installed” tab of the plugin manager.

Creating a New Job which clones from Git:

Navigate to back to the dashboard and click on “New Job” in the top left corner.

Jenkins “New Job” screen

In the next screen under “Source Code Management” section, select “Git” and add the url to the repository and the branch which you would like to checkout.

 

Cloning the Jenkins CI github Repository

Potential Issues:

Currently the Jenkin’s plugin does not support cloning private repositories using private key files with pass phrase. The solution which I am currently employing is to generate a private key file without a pass phrase.


This concludes the guide to setting up Jenkins to use with github (or rather even just general git repositories).

5 Comments

  1. Pingback: Emma and Jenkins | Derek Kwok's Blog

  2. do you have any idea how to set jenkins up so that it ONLY builds when the branch in “Branch Specifier” is changed? Github fires the post-receive service hook when any branch is pushed to, but we want to set up a jenkins job that only builds when the specified branch gets a new commit.

  3. This has probably been answered, but in case anyone is looking, you can use the “Poll SCM” build trigger in Jenkins, in combination with a “branch specifier” in the “Source Code Management” section of job configuration (assuming you have the git plugin installed) – and that will only build when the polling detects that the specified branch has been updated.

    • Instead of polling Github periodically, I think Michael Johnston wants to have Github fire a build request when there’s a new commit pushed to it. This means that Jenkins should receive the request to build instead of asking Github.

      Fortunately, it looks like the new Jenkins Github Plugin has a new feature: “Trigger a build when a change is pushed to GitHub”.

      The link to Github plugin for Jenkins: https://wiki.jenkins-ci.org/display/JENKINS/Github+Plugin

  4. Do you know if this plugin will operate the same, or at least provide the same functionality, with Github Enterprise?

Leave a Reply

Required fields are marked *.

*