2

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?

Eugene S
  • 6,709
  • 8
  • 57
  • 91
  • 1
    Which user runs the Jenkins service? It's _LocalSystem_ by default. See the answer to [The difference between the 'Local System' account and the 'Network Service' account?](https://stackoverflow.com/a/510225/1744774) for the implications. – Gerold Broser Jul 11 '17 at 10:25
  • 1
    @GeroldBroser Hi and thanks a lot for pointing me in this direction. I studied the linked question and it helped me to find a way to configure the service to run using my current user account instead of the default LocalSystem. Please post a full answer and I will accept it. Thanks. – Eugene S Jul 12 '17 at 01:01

1 Answers1

1

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.

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107