maandag 7 juni 2010

Getting started with Hudson & Eclipse

Why automated build?

After reading these two blog posts by Andrew Niefer here and here I understand that there is simply no way to build a custom updatable RCP application manually from Eclipse. The export options are too limited so I opened bug 316059 to make this exporting easier.

Why Hudson?

As the Eclipse building infrastructure itself is employing Hudson I expect that automating the build of RCP applications will be possible with Hudson. The first step is to download Hudson from hudson-ci.org. I installed it on my Mac in /usr/local/hudson/.

LaunchAgent

I don't like starting up Terminal to manually start it everytime so I created a LaunchAgent for it. Place the following plist xml in file /Library/LaunchAgents/org.hudson-ci.agent.plist and Hudson will start automagically every time on login.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.hudson-ci.agent</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-jar</string>
<string>/usr/local/hudson/hudson.war</string>
<string>--httpPort=9090</string>
</array>
<key>StandardErrorPath</key>
<string>/Library/Logs/hudson-err.log</string>
<key>StandardOutPath</key>
<string>/Library/Logs/hudson-out.log</string>
</dict>
</plist>

I employ one POJO jar in my RCP app and I managed to set this up in a few hours to extract from CVS, run checkstyle, findbugs, junit tests, emma tests code coverage and do final build. Next time I'll cover building a an Eclipse feature and update site.

Moving HUDSON_HOME (Added on 2010 06 11)

After some time I noticed that my home directory was increasing in size, leading to rapid and longer TmeMachine backups. I like the backups of my development tools to be different and under my direct (script) control so I needed to move the Hudson home directory. Luckily this can be done easily!

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Moving HUDSON_HOME to /_some_other_volume_/Hudson/ -->
<key>EnvironmentVariables</key>
<dict>
<key>HUDSON_HOME</key>
<string>/_some_other_volume_/Hudson/</string>
</dict>
<key>Label</key>
<string>org.hudson-ci.agent</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-jar</string>
<string>/usr/local/hudson/hudson.war</string>
<string>--httpPort=9090</string>
</array>
<key>StandardErrorPath</key>
<string>/Library/Logs/hudson-err.log</string>
<key>StandardOutPath</key>
<string>/Library/Logs/hudson-out.log</string>
</dict>
</plist>

Now copy everything using terminal:

$ cp -pR .hudson/ /_some_other_volume_/Hudson/
and restart Hudson.

$ ps -lA | grep hudson
501 _XXXX_ 565 4004 0 47 0 2972192 212840 - ↵
→ S a9a87e0 ?? 0:40.14 ↵
→ /usr/bin/java -jar /usr/local/hudson/hudson.war --httpPort=9090
$ kill _XXXX_
$ sudo launchctl list


Then try in your browser: And now everything appears to be located in the new location!