EC2 Continuous Deployment: Managing the build process

Note: This is the third article in the series on continuous deployment. If you want to start with the overview, go here.

We can now build our application manually, but need to automate the actual build process. For this I’ll be using the Hudson Extensible continuous integration engine. I’ve been using CruiseControl for many years, and while it does the job, I’ve been annoyed enough that I’ll try something new.

Add the source to a repository

All CI systems need to get the source from a SCM so that the code that is being built is in a well defined state. So let’s  add the source of the webapp to a SCM, in this case

$ git init
$ git add *
$ git remote add origin
$ git commit
$ git push origin master

Now all the sample code is available here

Install Hudson

While you could use Amazon EC2 to host your build server, it takes some time to configure with persistent storage, mail server etc. Since this is not the main focus of these articles, I’ll just use our existing Xen infrastructure. Provisioning a new server running Debian Lenny is simple (when xen-tools is configured correctly):

# xen-create-image --hostname buildserver --mac 00:16:3E:55:42:8E
# xm create /etc/xen/buildserver.cfg

Now sign in to the new VM and install the necessary prerequisite software:

# apt-get update && apt-get upgrade && apt-get install sun-java6-jdk git-core daemon subversion unzip
# git config --global ""
# git config --global "Your Name"

There seems to be a Debian repository for Hudson, but it’s very unstable so we’ll just install directly from the .deb files:

# cd /tmp && wget && dpkg --install hudson_1.303_all.deb

Install Gradle as previously described here.

Restart the server to make sure the service is started automatically. After you’ve done this, point your browser to the buildserver at port 8080. You should see something like this:


Install Hudson plugins

We need to configure a number of Hudson plugins, goto http://buildserver:8080/pluginManager/available and install the following plugins:

  • Git plugin – For access to
  • Gradle plugin – Since we use Gradle to build the software

Restart Hudson for the changes to take effect

# /etc/init.d/hudson restart


The Gradle plugin needs to be configured. Go to http://buildserver:8080/configure and enter the path


You should also configure SMTP as appropriate for your system. If you have a Gmail account, you can use this for sending email.

Setup smoke test to build on new commits

Now that we’ve installed and configured Hudson, it’s (finally) time to configure a smoke test to build whenever changes are comitted to the application. This build should be quick in order to provide quick feedback to developers on their last commit. I usually include the following:

  • Compile the entire application
  • Run all unit tests

but don’t include any packaging, integration tests or other long running test cases in this task. Incidentally? the above is eactly what happens when we execute the default test task on our Gradle build file.

The steps are

  • Click “New Job”
  • Enter jobname “Helloworld smoke test”
  • The type should be “Build a free-style software project”
  • Click “Ok”

On the next page, fill out the following sections and tweak as you see fit:



Press the “Build Now” link and the code should build. If you push any changes to github, the code should compile and you should receive an email if anything fails (compilation or tests).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: