我尝试使用以下命令Jenkins
在我的服务器上安装Ubuntu 20.04
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins
但安装失败dpkg: error processing package jenkins (--configure):
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 Sun 2021-01-24 20:09:16 UTC; 13ms ago
Docs: man:systemd-sysv-generator(8)
Process: 1620107 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)
Jan 24 20:09:16 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: Starting LSB: Start Jenkins at boot time...
Jan 24 20:09:16 ubuntu-s-1vcpu-1gb-nyc3-01 jenkins[1620107]: ERROR: No Java executable found in current PATH: /bin:/usr/bin:/sbin:/usr/sbin
Jan 24 20:09:16 ubuntu-s-1vcpu-1gb-nyc3-01 jenkins[1620107]: If you actually have java installed on the system make sure the executable is in the aforementioned path and that 'type -p java' returns the java executable path
Jan 24 20:09:16 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: jenkins.service: Control process exited, code=exited, status=1/FAILURE
Jan 24 20:09:16 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: jenkins.service: Failed with result 'exit-code'.
Jan 24 20:09:16 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: Failed to start LSB: Start Jenkins at boot time.
dpkg: error processing package jenkins (--configure):
installed jenkins package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
我试过了这个,删除并再次安装,改变的内容/etc/securetty
这里但它们都不起作用。我只有在尝试Jenkins
在服务器上安装时才会遇到这个问题,而我尝试在自己的笔记本电脑上安装时,Ubuntu 20.04
它运行正常。
答案1
$ sudo apt update
$ sudo apt install openjdk-11-jre
$ java -version
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2)
OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)
$ sudo apt-get install jenkins
官方文档: https://www.jenkins.io/doc/book/installing/linux/#installation-of-java https://www.jenkins.io/doc/book/installing/linux/#debianubuntu
答案2
使用 Java 8
sudo apt remove jenkins
sudo apt install openjdk-8-jdk
sudo apt install jenkins
使用 Java 11
sudo apt remove jenkins
sudo apt install openjdk-11-jdk
sudo apt install jenkins