Skip to content

Wakaleo Consulting

  Home Blog Installing Hudson as a Windows Service
  • Expertise in Continuous Integration and Continuous Delivery
  • Training and Mentoring in Test Driven Development
  • Expert Jenkins/Hudson training and mentoring
  • Expertise in quality development and testing practices
  • Training and Mentoring in Test Driven Development
  • Expertise in Continuous Integration and Continuous Deployment
  • Training and Mentoring in Test Driven Development
  • Training and Mentoring in Test Driven Development
  • Expertise in Automated Acceptance Tests and ATDD
Installing Hudson as a Windows Service PDF Print E-mail
Tuesday, 17 March 2009 12:00

I don't usually recommend using Windows for your build server, but sometimes you may not have a choice. You may be running Microsoft tools as an integral part of your build lifecycle, for example, or be constrained to use the local company standards. This article tells you how it can be done.

Hudson has a very convenient feature designed to make it easy to install Hudson as a Windows servers. There is currently no graphical installer that does this for you, but you get the next best thing - a web-based graphical installer.

First, you need to start the Hudson server on your target machine. The simplest approach is to run Hudson using Java Web Start (see http://wiki.hudson-ci.org/display/HUDSON/Meet+Hudson#MeetHudson-TestDrive). Alternatively, you can do this by downloading Hudson and running it from the command line, as you would normally do:

$ java -jar hudson.war

This second option is useful if the default Hudson port (8080) is already being used by another application. It doesn't actually matter too much which port you use - you can change this later. Next, connect to this server and go to the Manage Hudson screen. Here you will find an "Install as Windows Service" button. This will create a Hudson service on the server that will automatically start and stop Hudson in an orderly manner.

Hudson will prompt you for an installation directory. This will be the Hudson home directory (HUDSON_HOME). The default value is the default HUDSON_HOME value: a directory called ".hudson" in the current user's home directory. This is often not a good choice for a Windows installation. When running Hudson on Windows, you should avoid installing your Hudson home directory anywhere near your "C:\Documents And Settings" directory - not only is it a ridiculously long name, the spaces can wreak havoc with your Ant and Maven builds and any tests using classpath-based resources. It is much better to use a short and sensible name such as "C:\hudson".

Picture 2.png

A short home directory path is sometimes required for other reasons, too. On many versions of Windows (Windows XP, Windows Server 2003,...), file path lengths are limited to around 260 characters. If you combine a nested Hudson work directory and a deep class path, you can often overrun this, which will result in very obscure build errors. To minimize the risks of over-running the Windows file path limits (and without having to reformat your disk and install Ubuntu in its place, an option unfortunately not available to everyone ;-) ), you need to redefine the HUDSON_HOME environment variable to point to a shorter path in the hudson.xml file, as shown above.

This approach won't always work with Windows Vista. The best solution to this problem is to reformat your hard disk and install a proper operating system. If this is not a feasible option, then open the command line prompt as an administrator (right-click, "Run as administrator") and to execute the hudson.exe with the "install" option:

C:\hudson> hudson.exe install

This basic installation will work fine in a simple context, but you will often need to fine-tune your service. For example, by default, the Hudson service will be running under the local System account. However, if you are using Maven, Hudson will need an .m2 directory and a settings.xml file in the home directory. Similarly, if you are using Groovy, you might need a .groovy/lib directory. And so on. To allow this, and to make testing your Hudson install easier, make sure you run this service under a real user account with the correct development environment set up. Alternatively, run the application as the system user, but use the System Information page in Hudson to check the ${user.dir} directory, and place any files that must be placed in the user home directory here.

Picture 4.png

You configure the finer details of the Hudson service in a file called hudson.xml, in the same directory as your hudson.war file. Here you can configure (or re-configure) ports, JVM options, an the Hudson work directory. In the following example, we give Hudson a bit more memory and get it to run on port 8081:


<service>
  <id>hudson</id>
  <name>Hudson</name>
  <description>This service runs the Hudson continuous integration system</description>
  <env name="HUDSON_HOME" value="D:\hdn" />
  <executable>java</executable>
  <arguments>-Xrs -Xmx512m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\hudson.war" --httpPort=8081 --ajp13Port=8010</arguments>
</service>

Finally, if you need to uninstall the Hudson service, you can do one of two things. The simplest is to run the Hudson executable with the "uninstall" option: C:/hudson>hudson.exe uninstall The other option is to use the Windows service tool sc

C:/>sc delete hudson

Tags See All Tags Add New Tag...

Please Enter New Tags Separated By Comma's
  Or Close

Hudson  Windows Service 

Trackback(0)
Comments (4)Add Comment
0
hardysale
written by hardysale, February 08, 2010
Shoppers pay up to Cheap ED Hardy Shoes,Clothes lining. If you asylum’t experience the comfort of authentic
0
Discount Air Jordan
written by Discount Air Jordan , April 13, 2010
Wow! What an eclectic mix of Flash websites! I have to agree with others about the issue of SEO marketing with Flash, but you have to admit, these are very clever websites! Plus, it's fun to do something different. Flash is different and engaging, and you can't get these types of websites with HTML. Thanks for sharing!
Discount Air Jordan
0
jenkins Windows service stalls
written by Joe Breher, March 17, 2011
I am encountering an issue with running jenkins as a service. After a few minutes of operation, the service just stops. An attempt to restart it fails immediately with a dialog indicating the service stopped.

If I uninstall from command line, then reinstall through jenkins GUI, the service will operate for a few minutes before stopping again.

Do you have a suggestion for how I would debug this issue? Are there some logs I should be scrutinizing?

XP SP2 32-bit Pro, Jenkins 1.401 (failed similarly on 1.400).

Write comment

busy