Table Of Contents

Install Jenkins as a Windows service

NOTE: if you installed Jenkins using the windows installer, you shouldn't need to do anything else here because the windows installer automatically runs Jenkins as a windows service.

First, you need to start Jenkins before installing it. This can be done from JNLP, or by running "java -jar jenkins.war".

Now connect to Jenkins by going to the following URL http://<hostname>:8080/
Once Jenkins is started this way, look for the "Install as Windows Service" link in the "Manage Jenkins" page (requires Microsoft .NET framework version 2.0):

NOTE: The "Install as Windows Service" link indicated above will not appear if Jenkins is already running as a service on the machine. You can verifying that Jenkins is running as a service by launching the Services app from the Windows Start Menu and looking for a running service called "jenkins" among the list of all windows services running on the machine.

Clicking this link shows you the installation screen:

Choose the directory where Jenkins shall be installed (directory must already exist. If not create it before hand). This will become JENKINS_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 Jenkins.

This is to re-launch Jenkins 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 Jenkins, which is stored in the installation directory that you specified.

For W2K8 R2 users you may need to add C:\Windows\SysWOW64 to the PATH env var.

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

Install Slave as a Windows service (require .NET 2.0 framework)

Jenkins 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:

If the slave is supposed to start desktop applications you have to allow the service to interact with the desktop (Action->Properties->Logon->Allow service to interact with desktop).

Configure Slave Service to Run as Domain User (Windows Server 2008 R2 x64)

Warning: Hudson may reset this setting if it deploys a new Slave at any time.

On Windows Server 2008 R2 x64 to configure the service Jenkins to run as the desired domain user.

On the Jenkins install directory, grant All Privileges to the Jenkins domain user. You may have to delete all old LOG files, hudson-slave.err, hudson-slave.out, hudson-slave.wrapper and redirect for the service to start back up.

Install Slave as a Windows service (cmd version)

<serviceKey> is the name of the registry key that will define the service (this will not be displayed)<service display name> is the label that will identify the service in the service manager interface

Note that one space after the "=" for each option is mandatory.
Also note that this will not assign a description string to the service. This can be added by creating a new String value called Description in the registry, under

Launch Java Web Start slave agent via Windows Scheduler

If you are having trouble getting the Java Web Start agent installed as a Windows service an alternative method of starting the service automatically when Windows starts is to use the Windows Scheduler.

Changing the configuration of services

The JVM launch parameters of these Windows services are controlled by an XML file jenkins.xml and jenkins-slave.xml respectively. These files can be found in $JENKINS_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 jenkins slave service, run jenkins-slave.exe uninstall from the command line.

To uninstall the jenkins service, run jenkins.exe uninstall from the command line.

Troubleshooting

If the slave service doesn't start as intended, check the following locations for more information.

Look at the Windows event viewer under the application section for the logging output from Jenkins. This captures the key Windows service events, such as startup and termination

Look at the log files in the directory that jenkins.exe resides. They correspond to the standard output and the standard error from the slave process, and often Java stack traces are sent there.

No labels

35 Comments

Unknown User (citizenkahn@gmail.com)

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.

Unknown User (davesd)

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)

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."

Unknown User (newguy)

Unknown User (pradeepmsu)

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?

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

Unknown User (paolizq)

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.

Unknown User (rmorrey)

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?

Unknown User (espen@albrektsen.net)

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.

We installed the latest Jenkins (1.434) on our Windows 2008 Server Standard, but we don't see "Install as Windows Service" under Manage Jenkins.
This must be a stupid question but what are we doing wrong?

Java Web Start doesn't show the initial dialog.
Solution: Check the ports for Jenkins. I had a non-standard port and there were "other" areas still configured with the old port. I fixed my issue by reverting the config back to the default port
Solution: Check the folder specified actually exists and is writable by the JWS user

JWS hangs around in the background
Solution: Check the log inside your nominated slave install dir. For me, anonymous read access was disabled. I had to allow "Overall > Read" access to anonymous to make things work.

We're having the same problem described above with a Windows service slave being killed occasionally, but we're using Windows 7, and the instructions above are for older Windows options. How should I install the slave (to a Linux install of Jenkins) as a Windows service correctly on Windows 7?

Error 1053: the service did not respond to the start or control request in a timely fashion.

while running as a local windows service (no slaves or anything fancy like that) after installing a few plugins. It turns out that Windows services have a default timeout of 30 seconds when starting up. I was able to work around the problem by increasing the timeout length to a minute.

Edit the registry and set HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ServicesPipeTimeout to be a DWORD value in milliseconds. This is a global change for the timeout for all services.

Note that the author of that post considers exceeding the 30 second timeout to be a bad design, so perhaps it should be considered a bug when Jenkins takes to long to start/respond to the Windows Service system.

We have been running Jenkins from the command line for around 6 months, but wish to now run the master as a windows service. We run it from a d:/Jenkins dir currently. If I select install as a windows service, and point it to install into that directory, what might the consequences be? Will our jobs all remain, along with all our plug ins and other configuration? Or is the behaviour undocumented?

I am installing Jenkins 1.540 on windows server standard SP2. I have downloaded jenkins1.540.zip which have jenkins-1.540.msi and setup.exe in it. extracted files and when i run setup.exe it goes smooth and at end when in status it says starting jenkins as service through error in below picture. i am logged in as admin to machine. i tried to "run as administrator" and without it, get same error. any tips please!!

I am installing Jenkins 1.540 on windows server standard SP2. I have downloaded jenkins1.540.zip which have jenkins-1.540.msi and setup.exe in it. extracted files and when i run setup.exe it goes smooth and at end when in status it says starting jenkins as service through error in below picture. i am logged in as admin to machine. i tried to "run as administrator" and without it, get same error. any tips please!!

I am having a similar issue - I have attempted to install Jenkins on 3 separate machines using v. 1.540 both using command line -jar and the Windows installer. Each time Jenkins is able to successfully install but when the browser launches it cannot connect to Jenkins. Also, the Windows service has stopped. After restarting the service and attempting to access Jenkins via http://localhost:8080 through the browser again - the same issue occurs (can't connect via browser- windows service stopped again).

OS is Win 7 64-bit (I machine was VM, the other two were a laptop and and desktop).

I just want to inform you that you may adjust the requirement for .Net Framework 2.0. With a small change in jenkins-slave.exe.config, the service (which is written for .Net Framework 2.0) is then able to run on higher runtime Versions like 4.0 (3.* as well, but as far as I know a 2.0 version will run by default on Version 3.*). This change is very useful because it makes the service work by default on Windows Server 2012.

To apply this change, open jenkins-slave.exe.config for edit, and add the highlighted (bold) section: