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

http://blog.donnfelker.com/2010/10/26/setting-up-an-android-build-server-part-4/

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

Posts:

  • 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 GitHub.com. Sure, there aresome 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 GitHub.com 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 GitHub.com 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 example.com with your domain):

git config --global user.name "Build Server"

git config –global user.email “build@example.com”</pre>

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:

ssh git@github.com

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 Github.com’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 GitHub.com 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 GitHub.com for changes in the source. If a change is detected, the source will be pulled down to the server.

Setting up an Android Build Server – Part 3: Installing the Android SDK « Donn Felker

http://blog.donnfelker.com/2010/10/25/setting-up-an-android-build-server-part-3-installing-the-android-sdk/

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

Posts:

  • Part 4 – Communicating with GitHub
  • Part 5 – Creating a Hudson Build Job

In this post I’m going to show you how to install the Android SDK on an 64 bit Ubuntu 10.04 LTS headless server (no gui).

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!

Requirements

You will need to be running a machine which is capable of running X windows as I will be tunneling X windows through SSH in this section. I’m running a Mac OS X Snow Leopard and have had no problems with this.If you’re running any Linux Gui Workstation you should not have any issues (I assume).

You can also accomplish the same thing (from what I’m told) with PLink and PuTTy on a Windows operating system however I have never attempted it.

**If you do accomplish this with PuTTY and PLink, please comment so others can bask in the glory that you have accomplished! 

**

Installing the Android SDK

In order to install the Android SDK, you need to have access to the GUI. At the time of writing, there is now way to install the SDK without the gui (major downfall IMO).

Since I’m working on a headless server (no gui to work with) I need to tunnel the gui components to my local ssh connection where I do have X windows. As stated in the requirements, I’m running a Mac OS X Snow Leopard machine.

32 Bit Compatibility

The Android SDK currently supports 32 bit, not 64 bit. Therefore you will need to install a library before you can run the Android SDK. These library will allow you to run 32 bit programs in the 64 bit environment (if you’re running in 64 bit, that is).

To install these libraries, run the following command:

apt-get install ia32-libs

This will install the ia32-libs libraries. We can now run the Android SDK (shown below).

Downloading the Android SDK

We now need to downlaod the Android SDK. To do so, execute the following on the server:

cd ~

wget http://dl.google.com/android/android-sdk_r07-linux_x86.tgz</pre>

This .tgz file is from this url: http://d.android.com/sdk/index.html

wget is a command that will execute and go and get a file from the internet and copy it locally.

Once you’ve downloaded it locally and extracted it, follow STEPS 1 and 2 on the Android SDK set up, located here. We will be installing the necessary SDK versions in the sections that follow.

Gui Components

To install specific Android SDK’s we need to work with the Android GUI, and in order to do that we need to tunnel gui windows to your local machine through ssh -X (these are windows that would normally show up on a workstation or a headed server – server with a gui). To do this, you will need to install a library that allows the headless server to create some of the windowing infrastructure.

To add this library, run the following command:

apt-get install libswt-gtk-3.5-jni

Tunneling via SSH

The next part of this adventure begins with tunneling via SSH. But before we continue, a little background …

The Android SDK requires that you install the SDK from a GUI. There is no CLI for the SDK. If you’re on a headless server (a server without a gui) then you’re going to be up a creek. This is where tunneling via SSH comes into play. What you can do is tell your terminal window (in my case a terminal window on OSX) to use the -X option ssh. What does the -X option do? Take a look from the man page:

-X      Enables X11 forwarding.  This can also be specified on a per-host basis in

a configuration file.

X11 forwarding should be enabled with caution.  Users with the ability to

bypass file permissions on the remote host (for the user’s X authorization

database) can access the local X11 display through the forwarded connec-

tion.  An attacker may then be able to perform activities such as keystroke

monitoring.

For this reason, X11 forwarding is subjected to X11 SECURITY extension

restrictions by default.  Please refer to the ssh -Y option and the

ForwardX11Trusted directive in ssh_config(5) for more information.

X11 is basically the X Window system. By providing the -X switch we are asking SSH to bring the windows from the server to the local machine. If you’re running on a Linux maching (or OSX) you can do this with no problem. If you’re on Microsoft Windows, you’ll have to do some PuTTy and PLink magic. I’m not sure how to do it on Window though, but if you do, please post in the comments below.

By enabling X window tunneling, we can now launch the Android SDK from the server and bring it down to the server.

To connect with SSH tunneling you will need to start a new SSH connection with this command:

ssh -X username@yourserver.com

Next, navigate to your Android SDK installation folder, then navigate into the tools/ directory.

Note: When you tunnel windows via SSH, it will be SLOWWWWWW. Don’t expect super fast response time. If you click a window, or a button, or anything, it can take many seconds for it to respond. Therefore, before you continue, be ready to spend a good hour or so in front of the computer while the SDK downloads/installs on the server.

Now type:

./android update sdk

This will start the Android SDK manager and it will look something like this:

LOST IMAGE

Notice how the screens resemble the X Window system? This is because your tunneling the windows from a headless server down to your local machine.

Please remember, this stuff takes forever to download. So be VERY VERY VERY patient. Once you install your SDK’s you wont have to do it again until a new version comes out. So no need to fret, this only has to happen once!

Slowly go through the steps to install the SDK’s you need. The X Windows you’re using will download the files onto the server where the SDK needs them to be (platforms/ and add-ons/ directories).

Wrap Up

In this post you installed the necessary 32bit compatibility libraries and gui components needed to run the X Window system. After that you downloaded the SDK’s that you needed on your build server. In the next section we’ll tell Hudson how to get files from GitHub when they change (on a polling basis). After that we’ll go into actually building the Android app after the sources are cloned/fetched locally.

Setting up an Android Build Server – Part 2: Installing Hudson « Donn Felker

http://blog.donnfelker.com/2010/10/22/setting-up-an-android-build-server-part-2-installing-hudson/

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

Posts:

 

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

 

In this post I’m going to show you how to install Hudson CI on a 64bit Ubuntu 10.04 LTS headless server (no gui).

 

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!

 

Installing Hudson

 

Once you have Java installed you can install Hudson. Hudson can be installed as a Debian package, and that’s what I’m going to do here. You may want to look at the hudson installation documents as these instructions may be out of date (depending on when you found this site) or if you’re using a non-debian system.

 

The instructions on Hudson’s site can be found here:

http://wiki.hudson-ci.org/display/HUDSON/Installing+Hudson

 

Installing Hudson as a Debian package offers a few benefits:

 

  • Automatic upgrade of Hudson via apt
  • /etc/init.d hook up to start Hudson on boot

 

Here’s how I added Hudson CI to my Ubuntu 10.04 LTS server.

 

From the command line, type the following:

 

wget -O /tmp/key http://hudson-ci.org/debian/hudson-ci.org.key
sudo apt-key add /tmp/key

 

This will add a temporary key to the Hudson CI Debian repository and the second line will add the repository to the list of sources.

 

Now, it’s as simple as typing the following:

 

wget -O /tmp/hudson.deb http://hudson-ci.org/latest/debian/hudson.deb
sudo dpkg --install /tmp/hudson.deb

 

The first line gets the hudson.deb package file.

 

The second line installs Hudson.

 

Troubleshooting

 

Right after I ran:

 

wget -O /tmp/hudson.deb http://hudson-ci.org/latest/debian/hudson.deb
 sudo dpkg --install /tmp/hudson.deb

 

I received an error:

 

hudson: Depends: daemon but it is not installed

 

To fix this, you will need to install the hudson deamon by running the following command:

 

apt-get install hudson daemon

 

Now, re-run the following and you shouldn’t have any issues.

 

wget -O /tmp/hudson.deb http://hudson-ci.org/latest/debian/hudson.deb
sudo dpkg --install /tmp/hudson.deb

 

Updating Your Hudson Install

 

Once you’re Hudson CI is installed, its best for you to update it to make sure you have all the patches and updates possible. To get those updates, run the following command:

 

apt-get update; apt-get install hudson

 

This will update Hudson and make sure that Hudson is installed and up to date.

 

Wrap Up

 

Hudson is now installed. You should be able to go to your web browser and hit port 8080 on the server, such as http://example.org:8080 and Hudson will load. If you want Hudson to run under port 80, please see the Hudson documentation for instructions. I’m running mine on port 8080 with no problems. You should see a screen that looks similar to this:

 

LOST IMAGE

 

In the next post I’ll install the Android SDK and download all of the necessary SDK’s (Android versions) that we need to build our applications.

 

Pagination


© Daniele Lolli (UncleDan) 2000-2019. All rights reserved.

Powered by Hydejack v8.5.2