Eugene S
Eugene S

Reputation: 6910

Running Jenkins from command line vs as Windows service

I ran into a very strange issue. I need to configure proxy in my Jenkins to be able to access SVN repository in one of the jobs. I have done so in 2 ways:

  1. Started Jenkins from command line with the required arguments
  2. Started Jenkins as Windows service while the arguments are defined in the jenkins.xml file.

Starting from command line:

C:\>java -DJENKINS_HOME="C:\.jenkins" -Dhudson.model.DirectoryBrowserSupport.CSP
="`script-src 'unsafe-inline';`" -Dhttp.proxyHost=localhost -Dhttp.proxyPort=312
8 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -jar %JENKINS_HOME%\jenkins
.war

Starting as service (below is the jenkins.xml contents):

<executable>java</executable>
<arguments>-DJENKINS_HOME="C:\.jenkins" -Dhudson.model.DirectoryBrowserSupport.CSP="`script-src 'unsafe-inline';`" -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -jar "%JENKINS_HOME%\jenkins.war"</arguments>

So that's exactly the same. The issue however is that when I am using command line to start Jenkins, proxying works fine. But when I start Jenkins as service, the repo (through the proxy) cannot be accessed and I get this error message:

unable to access repository error

Please note that if I look at the System Properties in System Information section, the proxy parameters appear the same in both cases so the configuration is being applied properly:

System Properties

Apparently there is a difference in how Jenkins starts up depending on how it was started (command line or windows service). What reinforces this assumption is that I see that some log files are only being written when I start Jenkins as a service but not when I start it from command line. I am talking about these log files:

jenkins.wrapper.log
jenkins.out.log

What do I need to do differently to get the same result from Jenkins as service as I do when I start it from command line? What configuration am I missing?

Upvotes: 2

Views: 3529

Answers (1)

Gerold Broser
Gerold Broser

Reputation: 14762

Jenkins as a Windows service doesn't run under your current user but under the LocalSystem Account by default.

See MSDN: Using the LocalSystem Account as a Service Logon Account and SO: The difference between the 'Local System' account and the 'Network Service' account? for the implications.

Upvotes: 1

Related Questions