github with jenkins

Posted on Monday, January 27, 2014

This guide will go over installing the git plugin for Jenkins. It assumes you have Jenkins already installed and running (Very basic setup).  If you have not done that yet I wrote a how to guide at

As a side note there is a github plugin to Jenkins [1]  But I will not be going over that, rather I will just use the basic git plug-in to talk to github

Install git via apt-git

First git needs to be installed on the Ubuntu machine

> sudo apt-get install git

Install plug in

Open your Jenkins install in a web browser.  Mine happens to be located at

After you login click on Manage Jenkins

Click on Manage Plugins

Click on the Available Tab

In the filter enter "git plugin"
Then select "Git Plugin" and finally click on "Install without restart"

Plug-in installation starts

After the plug-in is successfully installed click on "Go back to the top page"

SSH keys

Create the ssh keys in the Jenkins home directory.  In my set up the Jenkins home directory is at /var/lib/jenkins

Switch over to the Jenkins user and create its ssh keys

> sudo su jenkins
> cd
> ssh-keygen -t rsa -b 2048

Copy the key to obtain it you could run the following command

> cat .ssh/

Copy this somewhere in order to upload it to github

Upload ssh keys to github

Login to github. 
From your profile click on SSH Keys

Click on Add SSH key

Give it a Title, Paste the text into the key and click Add Key


Open github repository

Click on New Job

Name it Test
Select "Build a free-style software project"
Click OK

At this point you need to get the url of a remote git repository to clone from.

For this example I chose jquery [2]

The URL to clone is located here on their github page, copy it.

In this case its

Replace the : with a / to give you and prefix it with ssh://


Now back to the Jenkins job page

Select "Git" then enter the github remote repository


Click Save

Click Build now

The Build was successful

This is a very simple deploy, all it does is download from the github repository.

This same technique works with closed github projects your github user has access to.

[1]        Jenkins github plugin
                Accessed 01/2014
[2]        jquery github site
                Accessed 01/2014

No comments:

Post a Comment