Saturday, 25 July 2009

Hudson for Java and Windows builds

Sometimes you might have both .Net and Java projects in your organization. When this happens you'll probably want to have a unified build server to display the outcome of all CI builds. Hudson has wonderful support for all aspects of Java building and also has some great integration for NAnt/NUnit/MSBuild/MSTest and even NCover for your .Net code coverage needs. This is great when you're building all your apps on the same OS but what happens when you want to build your Java apps on linux? Well Hudson has a solution for this too, Distributed Builds. This allows you to run a single master Hudson node with any number of slave nodes, which can all be different OS, Java/.Net versions, any configuration you want really.

Setting this arrangement up is very simple.

(This example describes setting up a Java master on linux and a .Net slave on Windows)

(On the master)
  • Install and start Hudson on the master box ( http://wiki.hudson-ci.org/display/HUDSON/Installation+and+Execution )
  • Create a node (Manage Hudson -> Manage Nodes -> New Node), the node name needs to be the ip or dns of the slave box and lauch should be via jnlp. Make sure usage is set to "Leave this machine for tied jobs only" or Hudson might start trying to run Java jobs on your windows box.

(On the slave)
  • Open a browser and go to the following url http://<ip>/computer/<node>/ (e.g. http://infrastructure.mycompany.com/hudson/computer/10.0.0.56/)
  • Click the big orange launch button
  • (One extra step if you want is to install the slave as a windows service. There is a menu option to do this on the slave agent window that opens on the slave box.)

And thats it, create your .Net jobs just like Java ones but make sure you check the "Tie this project to a node" option and select your .Net slave node.

NAnt, NUnit, MSBuild, MSTest and NCover support is available from the plugins menu.

Now at this point I should tell you about the gotcha. NAnt support doesn't seem to work when you run Windows as a slave service as the options for specifying tool locations (NAnt etc) only stretches to Java tools. If someone has managed to make it work please let me know. The workaround is to not use the NAnt support and use Windows batch commands, just enter the command you would do at a terminal window to run the build and Hudson will do it for you, simple :-)

No comments:

Post a Comment