Installing Hudson as a Windows service

This page describes the new installation procedure implemented in 1.254. The old page is still left for archival purpose

Install Hudson as a Windows service

First, you need to start Hudson before installing it. This can be done from JNLP, or by running java -jar hudson.war".
Now connect to hudson by going to the following URL http://<hostname>:8080/

Once Hudson is started this way, look for the "Install as Windows Service" link in the "Manage Hudson" page (requires .net framework version >= 2.0):


Clicking this link shows you the installation screen:


Choose the directory where Hudson shall be installed (directory must already exist. If not create it before hand). This will become HUDSON_HOME and used to store data files and programs alike.
Upon successful completion of the installation, you should see a page asking you to restart Hudson.


This is to re-launch Hudson as a newly installed Windows service. When you click yes, you'll be asked to wait until the restart completes:

If a restart fails for some reason, check the output from Hudson, which is stored in the installation directory that you specified.

At this point you can use the service manager to confirm that Hudson is running as a service.


Install Slave as a Windows service (require .Net 2 framework)

Hudson also allows you to install a slave agent as a Windows service. (See Distributed builds for more about how to do distribute builds in general.)

First, you configure your slave to run as a JNLP slave agent. This should create a JNLP launch icon in the corresponding page, as shown below:


From the slave machine, launch a slave agent. You should see a window like this:


Choose "File" > "Install as Windows Service" from the menu:


Confirm your intention to install as a service. The installation will place the program files to the directory designated as the slave root directory (from the "configure executors" screen.)


Once the installation succeeds, you'll be asked if you'd like to stop the current slave agent and immediately start a slave agent.


When you click "OK", the slave agent window will terminate. The new slave agent runs as a service without showing a window, so head over to the service manager from the control panel and confirm that the slave agent is indeed running as a service:


Install Slave as a Windows service (cmd version)

In a cmd execute the following command:

 sc.exe create HudsonSlave binPath= "C:\WINDOWS\system32\java.exe -jar C:\hudson\slave.jar
-jnlpUrl http://SERVER:PORT/computer/MACHINE/slave-agent.jnlp" start= auto

This is a very simple version, you can elaborate start scripts which use some program to hide the CMD window, select the good server and try to ping it, get the MACHINE variable with %computername% ,etc...

Unknown macro: {error}

This information is false. Service created like this will never report back their status to Windows service manager, so the service will reported as not responding and gets terminated. If you have done this, run "sc delete HudsonSlave" to delete the service created.

Changing the configuration of services

The JVM launch parameters of these Windows services are controlled by an XML file hudson.xml and hudson-slave.xml respectively. These files can be found in $HUDSON_HOME and in the slave root directory respectively, after you've install them as Windows services.

The file format should be self-explanatory. Tweak the arguments for example to give JVM a bigger memory.

Stdout and stderr from the service processes go to log files in the same directory.

Uninstallation

To uninstall the service, run hudson-slave.exe uninstall from the command line.

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
  1. Nov 07, 2008

    Peter Kahn says:

    If you run into an authentication problem (perhaps because you are using apache-...

    If you run into an authentication problem (perhaps because you are using apache-auth on your SVN server) you can force the service to cache the auth credentials by going to the *script console* and executing some groovy code that auths as the user you'd like to use.

    "cmd /c svn ls \--username builder \--password blah http://svn.host.com/svn/repos".execute()
    
  2. Feb 18, 2009

    Liya says:

    I work with version 1.276 installed on Windows XP and i don't have this option i...

    I work with version 1.276 installed on Windows XP and i don't have this option in the Manage Hudson page..

    VisualStudio 2008 is installed on the machine.

    Do i need to configure anything else?

  3. Mar 30, 2009

    gust says:

    I noticed that Hudson slave as a service must be configured Log on as account to...

    I noticed that Hudson slave as a service must be configured Log on as account to get slave's other drives to work. If Local System Account used Hudson job did not find other drives (E.

    Also there must be free space 1Gb available in slave Windows, otherwise connection (master<->slave) won't work. Pls correct me if I am wrong.

    -gust-

  4. Apr 07, 2009

    John Agar says:

    where can i find the hudson.war file for the installation? under download i jus...

    where can i find the hudson.war file for the installation?

    under download i just find a hudson.zip file.

    also, which version should be downloaded? they are all marked as stable? seems quite strange to me.

    1. Apr 21, 2009

      David Dull says:

      All you have to do is change the extension from zip to hpi. Windows is helping y...

      All you have to do is change the extension from zip to hpi. Windows is helping you!

  5. Apr 21, 2009

    David Dull says:

    Is anyone having problems w/ environment variables not matching? (windows XP) I...

    Is anyone having problems w/ environment variables not matching? (windows XP)

    If I go to manage hudson -> system information and display the environment variables the list is incomplete as compared to the list given when I just do a set command from DOS. (what's missing is the embedded compiler license)

    Thank you

  6. Jul 24, 2009

    cbrown says:

    I'm having trouble installing my Hudson slave agent as a service.  Whe...

    I'm having trouble installing my Hudson slave agent as a service.  When i select "File" > "Install as Windows Service" I receive the following error message:

         java.io.IOException: Cannot run program "/hudson-slave.exe" (in directory ""): CreateProcess eror = 267, The directory name is invalid

    Does anyone have any idea what could be causing this?  I have a master running on Ubuntu and two Windows Xp slaves.  The jnlp runs fine from the browser launch, but it won't install as a service.  When I attempt to install it from the command line the service won't start and it gives the error:

         "Could not start the HudsonSlave service on Local Computer.  Error 1053: the service did not respond to the start or control request in a timely fashion."

    Thanks

  7. Aug 19, 2009

    Frank says:

    Is there a way to restart Hudson manually through the user interface? I don't se...

    Is there a way to restart Hudson manually through the user interface? I don't see this anywhere. This would be much nicer than having to kill the process or restart the daemon in Unix.

  8. Aug 24, 2009

    Aditya Kumar Pandey says:

    To install the service, run hudson.exe install from the command line. It works

    To install the service, run hudson.exe install from the command line. It works

    1. Oct 15, 2009

      newguy says:

      Yeah, but before you install the service there is no hudson.exe. That exe file i...

      Yeah, but before you install the service there is no hudson.exe. That exe file is generated by the service.

  9. Feb 12, 2010

    Pradeep Bandi says:

    I am trying to configure Hudson-Slave on a VMWare machine. I was able to run tha...

    I am trying to configure Hudson-Slave on a VMWare machine. I was able to run that as a slave, but I am unable to configure it as “Install as a Windows Service”.  It is throwing following error (Even though it is not installed as a windows service the Hudson master is able to detect it as a slave and I am able to do a build also). I am unable to figure out what that error is for. By the same way, I am able to successfully install the slave as a windows service on a Windows-XP machine or on a Server 2003 machine.  I am thinking that Hudson is unable to create an interface with VMWare to install it as windows service. Can anyone help me out with this issue?

  10. Feb 17, 2010

    Jes struck says:

    after a have installed the slave service on my windows XP machine i go to Servic...

    after a have installed the slave service on my windows XP machine i go to Services and make service run under a specific userprofile, but after that it seems that the service won´t start... is there anyone that could give me a hint... please

  11. Mar 18, 2010

    Paoli says:

    I have a problem with Hudson in Windows. I've been able to install it as a servi...

    I have a problem with Hudson in Windows. I've been able to install it as a service without a problem and I've executed jobs successfully. The problem is that for one job in particular, I need to use the archive from the Last Successful build, however, the LastSuccessful and LastStable symbolic links are not created. I had already tested hudson under Linux and those symbolic links are created automatically upon executing jobs that are configured to archive the artifacts. I have this setting as well in the windows install, but the symbolic links are never created. I don't know if it's because I'm running on Windows and the creation of these links is simply not possible or maybe I'm missing something.

    Any ideas? Thanks.

  12. Jul 23, 2010

    Rex Morrey says:

    We installed Hudson as a service on a Sun server, but when we try to run a build...

    We installed Hudson as a service on a Sun server, but when we try to run a build on that server we get permission errors when trying to create folders or files or if we try to delete files or folders.  I inserted a "who" command into the script to determine what the username of the process is but nothing was displayed.  Can someone help me figure out how to determine the username the process runs under?

  13. Nov 08, 2010

    Espen Albrektsen says:

    Tried to install a slave on my laptop for local testing of builds, and got the (...

    Tried to install a slave on my laptop for local testing of builds, and got the (to me) strange error message:

     System.Management.ManagementException: Not found
       at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
       at System.Management.ManagementScope.InitializeGuts(Object o)
       at System.Management.ManagementScope.Initialize()
       at System.Management.ManagementScope.Connect()
       at WMI.WmiRoot..ctor(String machineName)
       at WMI.WmiRoot..ctor()
       at winsw.WrapperService.Run(String[] args)
       at winsw.WrapperService.Main(String[] args)
    

    After a little bit of googling - I realized the error is quite clear: System.Management is not found because I have not installed the .Net framework on my machine yet.
    Since hudson is running on Java, it never occured to me that .Net could be required, I am downloading the .Net 4.0 framework now.

    Installing .Net 4.0 does not solve the issue - and that makes sense - we would not get the System.Management.ManagementException unless some parts of the .Net framework was installed.

    This thread indicates I need to rebuild WMI: net.java.dev.hudson.users

    I followed the steps in this guide , and hudson slave now installed successfully on WinXP (32 bit)

    :-)