Wednesday, September 2, 2009

Hudson, maven and git on eapps.com VPS

VPS hosting from eapps.com is a reasonable compromise between cost and hosting service quality. I use it to host a hudson CI server.

This entry explains how I set it up up to a point where I can build using maven a java project hosted on a ssh protected git repository (on github). I will not go into the hudson specific stuff, the hudson wiki is usually complete & well worded. But I will spend more time on the OS specific stuff such as daemon configuration, ssh specifics, etc...



The files I used to start/stop/upgrade hudson are located on this github project. I've used them on several setup so far and I am happy with them. They probably could be improved and some features may be deprecated thanks to general improvement in hudson. I use them successfully on projects involving xvnc plugin, ssh connections, etc.

Enjoy and build early build often.

Hudson setup overview



  • installed under /opt/hudson

  • can be upgraded thanks to /opt/hudson/upgrade_hudson.sh (as root)

  • runs using java -jar hudson.war, together with ssh-agent



Installation worklog



Install Java 1.6 (JDK) using eapps control panel. Then proceed with the configuration.

As youruser:

mkdir ~/Code
cd ~/Code
git clone git://github.com/lacostej/my-hudson-nix-setup.git


Then, as root

adduser hudson
mkdir -p /opt/hudson
chown hudson:hudson /opt/hudson

mkdir -p /opt/latest
cd /opt/latest
ln -s /usr/lib/jvm/java-1.6.0 java # replace with what is the most appropriate on your server
# install my hudson scripts.
cd ~youruser/Code/my-hudson-nix-setup/
cp etc/init.d/hudson /etc/init.d/
cp opt/hudson/*.sh /opt/hudson/

chmod +x /opt/hudson/*.sh /etc/init.d/hudson

chkconfig --add hudson

/etc/init.d/hudson restart


Getting hudson to talk to github



Hudson above was configured to automatically use a default SSH key. This key should have no passphrase(*). Let's create it. As hudson user, generate a key (with _no_ passphrase)

> ssh-keygen
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/hudson/.ssh/id_rsa.
Your public key has been saved in /home/hudson/.ssh/id_rsa.pub.
The key fingerprint is:
ae:32:c2:f5:0f:ee:c8:2c:2b:62:3a:2c:6f:ab:25:e9 hudson@yourserver.virtual.vps-host.net


On github, add the public key to your account.

then let's configure git. As hudson user:

git config --global user.email "hudson@yourcompany.org"
git config --global user.name "MyCompany Hudson Daemon"


Configure Hudson security



I chose to Hudson's own user database and remove all anonymous browsing. Hudson wiki offers more choices.
From the Hudson main configuration page, chose
Enable Security
Hudson's own user database
Tick out Allow users to sign up

Matrix-based security
Add a new user called admin
Give him all permissions
Don't give any permissions to anonymous user.

Install maven


I install maven manually. wget from apache server/mirror, unzip under /opt.

Configure hudson



Open http://yourserver:8082/configure to

add a JDK (can point to /opt/latest/java if you feel like)
add maven
specify smtp server, from email
test SMTP

add your project (you probably want to add some notification, like emails or gtalk)

Follow up


Now there are plenty of small things left for you to work on

  • configure maven / and your artifact repository (e.g. nexus)

  • handle deployment / release etc..

  • ...



I may cover these topics in a later post.

2 comments: