Welcome to EMC Consulting Blogs Sign in | Join | Help

Random Ramblings of a Platform Architect

How to set up a windows AMI to use with elastic bamboo

Jira Studio uses elastic bamboo as its build controller which in turn uses elastic agents (AWS ec2 instances that are spun up by the build controller to run the build) rather than the standard remote agents. This means you will need to have an Amazon AWS account and will have to create a custom windows AMI to be used to create your elastic-agents. Unfortunately there are no available instructions on creating a custom elastic-agent for windows users so you have to use the Linux instructions as guide. This post outlines what I did to get this working for a recent project. Please note that this is unsupported by Atlassian but hopefully they’ll be supporting windows soon as from my experience it does all seem to work so far.

Please note that this post assumes you have some basic knowledge of using AWS.

 

Start a Windows 2008  instance from an  Amazzon base windows 2008 AMI in the us-east-1  region

It needs to be in the US-East region as this is where Jira Studio expects to find the build agent.

Using AMI

ami-d9e40db0

clip_image002

Turn off windows firewall or ensure you have port 22626 open

 

 

Ensure jre &/or  jdk installed and files from jdk that are needed are also in jre folder  if you decide to use the jre as your JAVA_HOME

You will need tools.jar in your JAVA_HOME path so   you will have to install the jdk to get that

Install whatever components you need to be able to undertake a build e.g visual studio, msbuild etc and other bits

 

 

Use the link here as a  guide

http://confluence.atlassian.com/display/BAMBOO/Creating+a+Custom+Elastic+Image

 

 

Set up the Amazon ec2 API tools as outlined in the Atlassian guide ( section 5.4)

Specific guidance for windows  can be obtained from the AWS documentation

To check the version of bamboo click on administration then expand under system \ system information 

clip_image004

Scroll down to see the Bamboo version

clip_image006

 

 

 

 

Download the bamboo-elastic-agent that matches the version of Bamboo that is being used in Jira Studio

http://www.atlassian.com/software/bamboo/BambooDownloadCenter.jspa

Make sure you click show all.

 

 

Create folder c:\bamboo-elastic-agent

 

 

Unzip the bamboo-elastic-agent-2.6.2.zip to folder created above

To the folder : c:\bamboo-elastic-agent

Add bin to path variable

c:\bamboo-elastic-agent\bin

Download  the latest zip of ant and unzip into c:\ant\

http://www.apache.org/dist/ant/binaries/

Set up environmental and path variables

 

 

Download the latest zip of maven

http://www.apache.org/dist/maven/binaries/

Unzip maven  into  c:\ apache-maven-2.0.11

 

 

Set up environment variable and path as done for ant

 

 

Summary of relevant Environment variables

ANT_HOME  C:/ant

EC2_CERT  c:\ec2-api-tools\YOUR-cert.pem

EC2_HOME  c:\ec2-api-tools

EC2_PRIVATE_KEY c:\ec2-api-tools\YOUR-pk.pem

JAVA_HOME  C:\Program Files\Java\jre6

MAVEN_HOME c:\apache-maven-2.0.11

Path  variables

.......  c:/ant\bin;C:\Program Files\Java\jdk1.6.0_23;c:\apache-maven-2.0.11\bin;C:\ec2-api-toolsbin;c:\bamboo-elastic-agent\bin

Create batch file that  consists of two lines

Line 1: the Java classpath ( This was obtained by using a simple Powershell script to scrape the lib folder under bamboo-elastic-agent  and setting the result as  a CLASSPATH  variable)

Line2: This will run the actual elastic-agent

Note there are over a  hundred jar files but to date Atlassian have been unable to let me know which ones are actually needed hence the snippet of the batch file I used  rather than the full list.

 

 

SET CLASSPATH=acegi-security-1.0.4.jar;activation-1.1.1.jar;activeio-core-3.1.0.jar;activemq-core-5.2.0.jar;activemq-ra-5.2.0.........

 

 

java -server -Xms32m -Xmx512m -XX:MaxPermSize=256m  -classpath %CLASSPATH% com.atlassian.bamboo.agent.elastic.client.ElasticAgentBootstrap 2>&1 > c:\bamboo-elastic-agent\bamboo-elastic-agent.log

Test that everything is set up okay by running the batch file interactively. You should see output similar that  opposite. The key points are it trying to get userdata and attempting to create the tunnel. The agent needs to be started by the bamboo controller hence the errors.

 

.........  Java.io.FileNotFoundException: http://169.254.169.254/2008-02-01/user-data
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
urce)
at java.net.URL.openStream(Unknown Source)

 

 

 

 

..........

oo.agent.elastic.client.ElasticAgentBootstrap

0 [main] INFO com.atlassian.bamboo.agent.elastic.client.ElasticAgentBootstrap  -

 Using tunnnelling. Registering 'httpt' and 'httpst' protocols.

577 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.se

rvice.tunnel.server.TunnelServer  - Waiting for tunnel connection.

The agent needs to start automatically on starting the instance

 

 

I looked at using the wrapper obtained via this url but that failed miserably

http://confluence.atlassian.com/pages/viewpage.action?pageId=91554194

I used the nssm  to wrap the batch file as a service

https://iain.cx/src/nssm/

Set it to start automatically

clip_image008

Create the AMI

 

 

Do the bamboo controller configuration & do some basic testing

Register the AMI,

Set up the capabilities , test that it will spin up the instance , test a basic build

 

 

clip_image010

 

 

clip_image012

 

 

clip_image010

 

 

clip_image014


 

 

 

 

PLEASE BE AWARE THAT IF YOUR BAMBOO CONTROLLER IS UPDATED YOU WILL NEED TO UPDATE YOUR ELASTIC-BAMBOO DISTRIBUTION AND CREATE A NEW AMI

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Published 18 January 2011 16:38 by Grace.Mollison

Comments

No Comments
Anonymous comments are disabled

About Grace.Mollison

Platform Architect .
Powered by Community Server (Personal Edition), by Telligent Systems