Configuring Hudson for grml autobuilds on EC2
Suppose you want to do automated builds of grml using the excellent grml-live framework, and host this in a nice autobuilder, like, Hudson. Also you don't have the necessary disk space, RAM, etc. locally so you want to use Amazon EC2 to host the worker machine.Install Hudson
- Download Hudson. (Actually grab hudson.war.)
apt-get install sun-java6-jdk
adduser --system --group --disabled-password hudson
su - hudson
java -jar hudson.war
Configure Hudson
- Use the plugin manager (Click 'Manage Hudson', -> 'Manage Plugins') to install the EC2 plugin. Restart hudson afterwards. (It may take a while until all available plugins are listed. Be patient.)
- Configure the basics ('Mange Hudson' -> 'Configure system'):
- Set "# of executors" to
0
. This effectively disables any builds on the master. - In the "Cloud" section add "Amazon EC2".
- Configure Access Key, Secret Key and EC2 RSA private key. (First two are in your Amazon EC2 Credentials, the RSA private key can be created using the EC2 Management Console by using the 'Create keypair' function.)
- Add an AMI:
- AMI ID:
ami-fcf61595
(current AMI ID from alestic.com for Debian squeeze server 64bit) - Instance Type:
LARGE
(the Alestic AMI won't work with the SMALL type) - Description:
Debian 6.0 server 64bit (Alestic) US
- Remote FS Root:
/mnt/hudson
(where the hudson slave will store it's local data. /mnt is the large disk for EC2.) - Labels:
debian-6.0-amd64
(AMIs with the same label will be grouped by Hudson) - Init Script:
wget -q http://your.web.server/hudson-slave.run && bash hudson-slave.run
(Get my hudson-slave.run and copy it to a web server reachable by your EC2 instances.)
- AMI ID:
- Save.
Setup a build job
Now create a new job for building grml. Job name can be "grml-small amd64 testing" or whatever you actually build :-)Choose "Build a free-style software project" as the proper option.
Configure your job
From the job dashboard choose your job, and select "Configure".Check "this build is parameterized" and add two String parameters:
- Name:
FLAVOUR
- Default Value:
grml-small
- Name:
CLASSES
GRMLBASE,GRML_SMALL,AMD64
Execute shell step #1:
#!/bin/bash echo "setup system and cleanup" set +e set +x apt-get install -y mksh fai-client fai-server fakeroot squashfs-tools squashfs-lzma-tools bc perl apt-get install -y grml-live grml-live-addons cat > /etc/grml/grml-live.local << EOF GRML_LIVE_SOURCES=" deb http://localhost/apt-cacher/http.us.debian.org/debian squeeze main contrib non-free deb http://localhost/apt-cacher/deb.grml.org/ grml-stable main deb http://localhost/apt-cacher/deb.grml.org/ grml-testing main " FAI_DEBOOTSTRAP="squeeze http://localhost/apt-cacher/http.us.debian.org/debian" #SQUASHFS_OPTIONS="-nolzma" SUITE="squeeze" CLASSES="${CLASSES}" VERSION="${BUILD_ID}" EOF grep /grml /proc/mounts | awk '{print $2}' | sort -r | xargs umount rm -rf /grml rm -rf work mkdir -p work
Execute shell step #2:
#!/bin/bash echo "actual build" set -x set -e mkdir -p /grml mount -t tmpfs -o suid,dev none /grml cd /grml set +e grml-live -g ${FLAVOUR} -F RC=$? set -e cd - mv /grml/grml-live/grml_isos/* work/ umount /grml exit $RC
For post-build Actions you'll want to check "Archive the artifacts" and use "work/**/*.iso" as the files to archive. This way the built ISO will be copied to the Hudson master.
Test it
After saving your job config, do a test run by clicking "Build now". After a few moments you should see a build running, and console output should show grml-live doing it's work!You obviously want to customize the parameters to your job as well as the first shell fragment, if you want to build something different than some grml-small amd64 ISO ;-)