java命令启动jenkins,从命令行和Windows服务运行Jenkins

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:

Started Jenkins from command line with the required arguments

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

java

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

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:

a4bK1.png

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:

iLuUI.png

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?

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值