A Free EC2 Cloud Based Jenkins And Sonar Setup

how-to
Aug 3, 20113 mins

Introduction

My original blog showed how to seperate maven unit and integration tests when doing continuous integration.

https://johndobie.blogspot.com/2011/06/seperating-maven-unit-integration-tests.html

This example builds on this to provide a platform to run the example.  We use a free Amazon EC2 cloud based solution to show how to deploy Jenkins and Sonar.  This is a low power server but it is useful for infrequent use.

The steps are very simple

  • Sign up for a 1 year free account from Amazon
  • Create a new server from an existing image with Hudson and Sonar.

Viewing The Final Platform

You can see an example of the finished platform by clicking on the links below.

Jenkins : https://ec2-75-101-221-43.compute-1.amazonaws.com:8080/

Sonar :   https://ec2-75-101-221-43.compute-1.amazonaws.com:9000/

Creating A Free Amazon Account

Amazon offer a free account for new customers. First sign up for the account at the following link.

https://aws.amazon.com/free/

Creating A Free Server

The free account only allows you to use a restricted set of images and a micro server.

Follow the steps below to create the server.

The first step is to log into the main Amazon console.  https://console.aws.amazon.com/s3/home

Go to the EC2 Tab and Click ‘Launch Instance’

Next we have to choose the correct image.  Go to the community tab and look for the following image.

ami-5d5f9234

 Notice the ‘Star’ which shows it is free tier eligible if chosen with a Micro Instance.

This brings up the screen below.  Notice the type ‘Micro (t1.micro, 613MB).

Leave the defaults and click on ‘Continue’

Again leave the defaults and click on continue.

Once again leave the defaults and click on continue.

Create Key Pair

This key pair is important because it is needed to connect to your server. Click on the ‘Create & Download your key pair’.  Keep the file safe.

Creating A Security Group

The next screen allows you to define the firewall rules for your server.  

 We are going to allow all of the following rules below.  You can make it more restrictive if you like once everything is running.

Instance Details.

The details of your new server will then be summarised. 

Click

 

Click on ‘Launch’ to start the server.

Tools to connect to your Server

You will need to connect to your server to install the applications. To do this download and install putty.

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

This will give you all the tools you need to connect to the server.

Converting Your Security Key

Before you can use putty to login you need to convert the .pem key from step 1 to a .ppk key.

Go to your installation of putty and run puttygen.

Select load and choose your downloaded .pem file.  You should see the dialog below.

Next click on ‘Save Private key’ and save the file somewhere safe.

Connecting To your Server

run putty

– First fill in the in the server name

Next click on the SSH -> Auth property.  Browse to the new .ppk file and select it.

Then click open.

This should give you a terminal window as follows showing you connected to your ec2 instance.

Installing Java

Installing Unzip

Installing Jenkins

We use the following commands to install Jenkins.

Installing Hudson

TBD