春节归来 Jenkins异常

背景

假日回来,测试人服务器拿ROM包,发现Jenkins的daily build停留在 2月10日,最新的没有生成。

分析定位

重启Jenkins

不管三七二十一,先service restart,发现启动失败

******@bsp-ubuntu1804:~$ service jenkins restart
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'jenkins.service'.
Authenticating as: dengsl (bsp)
Password: 
==== AUTHENTICATION COMPLETE ===
Job for jenkins.service failed because the control process exited with error code.
See "systemctl status jenkins.service" and "journalctl -xe" for details.

提示启动失败,按照提示 查看相关状态

debug

log分析
sudo systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: failed (Result: exit-code) since Wed 2021-02-24 10:24:56 CST; 44s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 9494 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)

Feb 24 10:24:56 bsp-ubuntu1804 systemd[1]: Starting LSB: Start Jenkins at boot time...
Feb 24 10:24:56 bsp-ubuntu1804 jenkins[9494]: Found an incorrect Java version
Feb 24 10:24:56 bsp-ubuntu1804 jenkins[9494]: Java version found:
Feb 24 10:24:56 bsp-ubuntu1804 jenkins[9494]: openjdk version "11.0.9.1" 2020-11-04
Feb 24 10:24:56 bsp-ubuntu1804 jenkins[9494]: OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)
Feb 24 10:24:56 bsp-ubuntu1804 jenkins[9494]: OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)
Feb 24 10:24:56 bsp-ubuntu1804 jenkins[9494]: Aborting
Feb 24 10:24:56 bsp-ubuntu1804 systemd[1]: jenkins.service: Control process exited, code=exited status=1
Feb 24 10:24:56 bsp-ubuntu1804 systemd[1]: jenkins.service: Failed with result 'exit-code'.
Feb 24 10:24:56 bsp-ubuntu1804 systemd[1]: Failed to start LSB: Start Jenkins at boot time.

关键log Found an incorrect Java version

ask google

google后 获取solution
同时Jenkins 对应的issue 已经fix。

具体为:JAVA_VERSION 不对,修改jenkins 脚本 使得 有效。

sudo vim /etc/init.d/jenkins 

JAVA_VERSION=$($JAVA -version 2>&1 | sed -n ';s/.* version "\(.*\)\.\(.*\)\..*".*/\1\2/p;')

改为:

JAVA_VERSION=$($JAVA -version 2>&1 | sed -n ';s/.* version "\([0-9]*\)\.\([0-9]*\)\..*".*/\1\2/p;')
* * *
 57 # Which Java versions can be used to run Jenkins
 58 JAVA_ALLOWED_VERSIONS=( "18" "110" )
 59 # Work out the JAVA version we are working with:
 60 JAVA_VERSION=$($JAVA -version 2>&1 | sed -n ';s/.* version "\([0-9]*\)\.\([0-9]*\)\..*".*/\1\2/p;')
 * * *

验证

直接启动,提示重新导入,按照要求重新导入

****@bsp-ubuntu1804:~$ sudo systemctl start jenkins 
Warning: The unit file, source configuration file or drop-ins of jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.
****@bsp-ubuntu1804:~$ sudo systemctl daemon-reload

导入后,再启动 正常

****@bsp-ubuntu1804:~$  sudo systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: active (exited) since Wed 2021-02-24 10:31:26 CST; 30s ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 0 (limit: 7372)
   CGroup: /system.slice/jenkins.service

Feb 24 10:31:25 bsp-ubuntu1804 systemd[1]: Starting LSB: Start Jenkins at boot time...
Feb 24 10:31:25 bsp-ubuntu1804 jenkins[9746]: Correct java version found
Feb 24 10:31:25 bsp-ubuntu1804 jenkins[9746]:  * Starting Jenkins Automation Server jenkins
Feb 24 10:31:25 bsp-ubuntu1804 su[9798]: Successful su for jenkins by root
Feb 24 10:31:25 bsp-ubuntu1804 su[9798]: + ??? root:jenkins
Feb 24 10:31:25 bsp-ubuntu1804 su[9798]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Feb 24 10:31:25 bsp-ubuntu1804 su[9798]: pam_unix(su:session): session closed for user jenkins
Feb 24 10:31:26 bsp-ubuntu1804 jenkins[9746]:    ...done.
Feb 24 10:31:26 bsp-ubuntu1804 systemd[1]: Started LSB: Start Jenkins at boot time.

访问Jenkins

一切正常

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lin_AIOS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值