背景
假日回来,测试人服务器拿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
一切正常