共计 1202 个字符,预计需要花费 4 分钟才能阅读完成。
jenkins 升级后启动失败,查看状态!
[root@xxx]$systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2023-06-16 09:47:33 CST; 28s ago
Process: 2563015 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
Main PID: 2563015 (code=exited, status=1/FAILURE)
Jun 16 09:47:33 lzysg-ops-01 systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 5.
Jun 16 09:47:33 lzysg-ops-01 systemd[1]: Stopped Jenkins Continuous Integration Server.
Jun 16 09:47:33 lzysg-ops-01 systemd[1]: jenkins.service: Start request repeated too quickly.
Jun 16 09:47:33 lzysg-ops-01 systemd[1]: jenkins.service: Failed with result 'exit-code'.
Jun 16 09:47:33 lzysg-ops-01 systemd[1]: Failed to start Jenkins Continuous Integration Server.
这里也无法看清楚具体的报错信息,然后查看 messages 日志发现如下问题启动时 java1.8
因为我 jenkins 是 apt 安装的所以配置了源,升级时会覆盖原来的 systemctl 配置文件,因为打包环境,我安装了多版本的 java
解决办法
vim /lib/systemd/system/jenkins.service
Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
就可以了,如果你指定了工作目录还需要修改下
Environment="JENKINS_HOME=/data/jenkins_data"
WorkingDirectory=/data/jenkins_data
上面的方式会导致每次更新都需要修改,建议直接修改下面的配置文件解决问题!
vim /etc/default/jenkins
然后执行
systemctl daemon-reload
systemctl start jenkins
正文完