Setting up an Android Build Server – Part 4: Communicating With Github

This post is part 3 in a series of posts of how to set up an Android build server.


* Part 1 – The Server
* Part 2 – Installing Hudson
* Part 3 – Installing the Android SDK
* Part 4 – Communicating with GitHub (this post)
* Part 5 – Creating a Hudson Build Job

In this post I’m going to show you how to install set up communication between an 64 bit Ubuntu 10.04 LTS headless server (no gui) with GitHub.

Note: I did this about 2 months ago. If you see any typos or find any errors, please comment so I can fix them. Thanks!

Communicating with GitHub

I’m using git for my version control repository, and I’m hosting it at Sure, there are some free git hosting sites, but I prefer to use GitHub because when I work with a team of developers or an offsite client, I can fire up a repository (public or private if you have a paid account) and everyone can connect quite easily. In the mobile world, most users are familiar with Git (at least in my experience).  While this is all well and dandy, what we really need is a way for Hudson CI to know when someone has checked in some new code. To do that, Hudson must be able to speak to GitHub through the server. In order to do that we’ll have to do the following:

  • Install Git on the server
  • Set up an SSH Key for the ‘hudson’ user in the system.
  • Initialize a repository in the Hudson work area.
  • Tell Hudson where the repository is at so it can poll for changes.

Installing Git on the Server

Thankfully, installing Git on the server is quite painless. To do so, run the following command once you’re logged into your server:

apt-get install git-core

This will install git into your server. You may have to log out and log back in for your PATH variables to be updated. Once the PATH variables are updated you can type “git” and you will see a list of available options.

Setting up the SSH Key

When you work with Git, you have to get familiar with SSH and SSH keys. This is pretty easy when you’re working on your workstation or a regular server with a normal user id. In the Step 2, we set up Hudson as a CI server, and Hudson runs under a locked down ‘hudson’ account (aka: non-interactive – meaning you cannot log in as ‘hudson’). Therefore creating an SSH key for this little guy gets tricky. Here’s how to do it.

Back Up the ‘hudson’ Users Existing SSH Key

Before we create a new SSH key for the ‘hudson’ user, you’ll want to back up the existing one. To do so, type the following command:

cp /var/lib/hudson/.ssh/id_rsa* /var/lib/hudson/.ssh/key_backup/

This will copy the public and private key pair into a backup folder (just in case you need it in the future for any reason).

Creating a new SSH Key

I’m going to log into the server and then ‘su’ to hudson and then I’ll follow the Help pages for setting up an SSH key and I’ll add that key to my allowed SSH Keys in GitHub, on the project web page.

First things first, log into your server. Now, you’re going to ‘su’ into the ‘hudson’ user account. Type the following to su into the hudson account:

su hudson

Now follow the steps in the Help Page for creating SSH Keys.

Setting The Servers Git Identity

When the server communicates with GitHub, we want the build server to have a known identity. Therefore we’ll need to set the Git username and email for the user. Type the following into the command prompt to set them (replacing with your domain):

git config --global "Build Server"

git config --global ""

Now, when the server communicates with GitHub it will be known as “Build Server” and will have the email you specified.

Connecting to GitHub

Finally, we need to connect to GitHub to have the server set up its initial RSA keys with the GitHub servers. To do that, type the following:


You will be prompted to verify if you want to connect. Type “yes” and press enter. You will the be connected and immediately disconnected from’s servers. At this point, the ‘hudson’ user can now talk to GitHub!

Wrap Up

In this post you installed Git and connected it to after setting up your SSH Keys. In the next step, I’ll show you how to create a new Hudson build job and how to have hudson poll for changes in the source. If a change is detected, the source will be pulled down to the server.

Android Dev Digest

Get the best Android Developer posts delivered weekly to your inbox.

Don't worry, I wont spam (I hate that stuff too).

  • Shaun McCloud

    How’s the Hudson build job post coming along?

  • Donn Felker


    The post is not coming along well. Mainly because I’m having trouble with a
    build step and its blowing up the build. So if you’re using something like
    roboguice it just blows up the build server. Memory overflow. Plus, Hudson
    has now been taken over by Oracle, and the Open Source version is now called
    Jenkins. So I’ll have to update this all once again. :

    Sorry for the delay.

  • Yangzhifang2006

     私たちは今まで、語る春トレンドのハンドバッグの明らかなように、がたくさんあります。私たちを持った コーチ アウトレットcoach バッグコーチ アウトレット、今日私はあなたに教えるのはもうひとつ傾向;花卉の模様が入っている。私たちは普段はこのコーチはコーチ バッグコーチの財布がなくて、しかし私はこのpurseblogの特徴がありす。コーチ 財布コーチ サングラスコーチ トート

  • Coach Factory Outlet

    It’s good to see this information in your post