Tuesday, May 18, 2010

Hudson Continuous Integration

Start with Subversion

Create a temporary project structure:
[greg:~] mkdir /tmp/taxi /tmp/taxi/trunk /tmp/taxi/branches /tmp/taxi/tags
Import the temporary project structure then delete it and switch to the source folder:
[greg:~] svnadmin create /Library/Subversion/Repository/taxi 
[greg:~] svn import /tmp/taxi file:///Library/Subversion/Repository/taxi -m 'initial import'
Adding         /tmp/taxi/trunk
Adding         /tmp/taxi/branches
Adding         /tmp/taxi/tags

Committed revision 1.
[greg:~] rm -rf /tmp/taxi
[greg:~] cd dev/src/java/taxi
[greg:taxi] cd ..
Checkout the empty project:
[greg:java] svn co file:////Library/Subversion/Repository/taxi 
A    taxi/trunk
A    taxi/branches
A    taxi/tags
Checked out revision 1.
Finally, start the server and list the projects:
[greg:java] svnserve -d -r /Library/Subversion/Repository
[greg:java] svn list svn://localhost/taxi
branches/
tags/
trunk/
[greg:java] cd taxi 
Create the source and commit it:
[greg:taxi] svn add trunk/src
A         trunk/src
A         trunk/src/main
A         trunk/src/main/java
A         trunk/src/main/java/Taxi.java
[greg:taxi] svn commit -m 'added swing program'
Adding         trunk/src
Adding         trunk/src/main
Adding         trunk/src/main/java
Adding         trunk/src/main/java/Taxi.java
Transmitting file data .
Committed revision 2.
[greg:taxi] 
[greg:taxi] svn add trunk/taxi.png
A  (bin)  trunk/taxi.png
[greg:taxi] svn commit -m 'added taxi icon'
Adding  (bin)  trunk/taxi.png
Transmitting file data .
Committed revision 3.
[greg:taxi] 
Start Hudson by using the Java Web Start instance found at http://www.continuous-integration-with-hudson.org or by running the jar as follows:
[greg:hudson] java -jar hudson.war --httpPort=8282
And now, open your browser to http://localhost:8282 and click on the "Manage Hudson" link and then the "Configure System" link. Here. I simply unselected the checkbox for "Install Automatically" and entered the values for Maven home and Java home. Save your changes.

Now, click on the "New Job" link. All that is required here is to enter a project name and, under 'Source Code Management', select Subversion and enter the value for the project's repository URL. I entered the value I used above:
file:////Library/Subversion/Repository/taxi

I saved my changes and ran a manual build which ran satisfactorily. Then, I clicked on the 'Configure Job' link and selected a build trigger of 'Poll SCM' which caused the display of the 'Schedule' prompt. Clicking on the question mark brought up helpful hints and examples. I selected the choice for 'every minute' and pasted it in the Schedule input field. Click 'Save'.

Now, simply commit a source file and, in less than one minute, Hudson shows a new build has been completed.