【发布时间】:2021-02-17 12:06:52
【问题描述】:
Jenkins 已作为 Windows 服务启动并运行了几个月,没有出现任何问题。
我做了一些 Jenkins 更新(将更新/更新的 .war 文件复制到 .jenkins 文件夹)并且还发生了一些 Windows 更新。我拥有的版本是 Jenkins 2.263.3。
我对文档和其他 StackOverflow 票证进行了大量的搜索,发现 JENKINS_HOME 环境变量丢失了。我添加了这个。
这是我的调查所揭示的。
- Java 环境变量已设置 - 见下文:
C:\>java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
- JENKINS_HOME 环境变量已设置 - 见下文:
C:\>echo %JENKINS_HOME%
C:\Users\XXXXX\.jenkins
<service>
<id>jenkins</id>
<name>Jenkins</name>
<description>This service runs Jenkins automation server.</description>
<env name="JENKINS_HOME" value="%BASE%"/>
<!--
if you'd like to run Jenkins with a specific version of Java, specify a full path to java.exe.
The following value assumes that you have java in your PATH.
-->
<executable>java</executable>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
<!--
interactive flag causes the empty black Java window to be displayed.
I'm still debugging this.
<interactive />
-->
<logmode>rotate</logmode>
<onfailure action="restart" />
<!--
In the case WinSW gets terminated and leaks the process, we want to abort
these runaway JAR processes on startup to prevent corruption of JENKINS_HOME.
So this extension is enabled by default.
-->
<extensions>
<!-- This is a sample configuration for the RunawayProcessKiller extension. -->
<extension enabled="true"
className="winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension"
id="killOnStartup">
<pidfile>%BASE%\jenkins.pid</pidfile>
<stopTimeout>10000</stopTimeout>
<stopParentFirst>false</stopParentFirst>
</extension>
</extensions>
<!-- See the referenced examples for more options -->
</service>
- 我可以从命令行启动 Jenkins,如下所示:
java -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "C:\Users\XXXXX\.jenkins\jenkins.war" --httpPort=8080 --webroot="C:\Users\XXXXX\.jenkins\war
-
如果我尝试从 Serice Manager 启动它,我会收到此错误 - System.BadImageFormatException
-
最后一件事,一旦我从命令行启动 Jenkins,并登录到应用程序,我注意到以下 Jenkins 系统日志:
Feb 17, 2021 10:29:31 AM INFO hudson.WebAppMain$3 run
Jenkins is fully up and running
Feb 17, 2021 10:29:57 AM WARNING hudson.lifecycle.WindowsServiceLifecycle getBaseDir
Could not find environment variable 'BASE' for Jenkins base directory. Falling back to JENKINS_HOME
对如何通过服务管理器启动服务有什么建议吗?
【问题讨论】:
标签: jenkins