Failed to start LSB Start Jenkins at boot time

#Failed to start LSB: Start Jenkins at boot time.

启动时报错

1
2
3
4
sudo systemctl restart jenkins.service
systemctl status jenkins.service
journalctl -xe

报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Job for jenkins.service failed because the control process exited with error code.
See "systemctl status jenkins.service" and "journalctl -xe" for details.
invoke-rc.d: initscript jenkins, action "start" failed.
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: failed (Result: exit-code) since Fri 2020-10-16 08:13:34 UTC; 70ms ago
Docs: man:systemd-sysv-generator(8)
Process: 18357 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)

Oct 16 08:13:32 ubuntu systemd[1]: Starting LSB: Start Jenkins at boot time...
Oct 16 08:13:34 ubuntu jenkins[18357]: Found an incorrect Java version
Oct 16 08:13:34 ubuntu jenkins[18357]: Java version found:
Oct 16 08:13:34 ubuntu jenkins[18372]: openjdk version "14.0.1" 2020-04-14
Oct 16 08:13:34 ubuntu jenkins[18372]: OpenJDK Runtime Environment (build 14.0.1+7-Ubuntu-1ubuntu1)
Oct 16 08:13:34 ubuntu jenkins[18372]: OpenJDK Server VM (build 14.0.1+7-Ubuntu-1ubuntu1, mixed mode, sharing)
Oct 16 08:13:34 ubuntu jenkins[18357]: Aborting
Oct 16 08:13:34 ubuntu systemd[1]: jenkins.service: Control process exited, code=exited, status=1/FAILURE
Oct 16 08:13:34 ubuntu systemd[1]: jenkins.service: Failed with result 'exit-code'.
Oct 16 08:13:34 ubuntu systemd[1]: Failed to start LSB: Start Jenkins at boot time.

主要原因是系统自带的tomcat 占用了8080端口

如果你的/etc/init.d/jenkins文件无法启动Jenkins,编辑/etc/default/jenkins, 修改 —-HTTP_PORT=8080—-为----HTTP_PORT=8081---- 在这里,“8081”也可被换为其他可用端口。

###: 修改启动用户为root

###: 使用java14

报错:

1
2
3
4
5
6
7
8
9
Oct 16 09:02:57 ubuntu jenkins[15764]: Found an incorrect Java version
Oct 16 09:02:57 ubuntu jenkins[15764]: Java version found:
Oct 16 09:02:57 ubuntu jenkins[15779]: openjdk version "14.0.1" 2020-04-14
Oct 16 09:02:57 ubuntu jenkins[15779]: OpenJDK Runtime Environment (build 14.0.1+7-Ubuntu-1ubuntu1)
Oct 16 09:02:57 ubuntu jenkins[15779]: OpenJDK Server VM (build 14.0.1+7-Ubuntu-1ubuntu1, mixed mode, sharing)
Oct 16 09:02:57 ubuntu jenkins[15764]: Aborting
Oct 16 09:02:57 ubuntu systemd[1]: jenkins.service: Control process exited, code=exited, status=1/FAILURE
Oct 16 09:02:57 ubuntu systemd[1]: jenkins.service: Failed with result 'exit-code'.
Oct 16 09:02:57 ubuntu systemd[1]: Failed to start LSB: Start Jenkins at boot time.
1
2
3
4
5
6
7
8
9
10
11
12
13
sudo vi  /etc/default/jenkins
# 将JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"
改为
#JENKINS_ARGS="--enable-future-java --webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"


sudo vi /etc/init.d/jenkins
# 将JAVA_ALLOWED_VERSIONS=( "18" "110" ) 改为
# JAVA_ALLOWED_VERSIONS=( "18" "140" )

#刷新daemon
sudo systemctl daemon-reload && sudo systemctl restart jenkins.service
cat /var/log/jenkins/jenkins.log