Jenkins 的安装需要 Java8 或更高版本,但你正在运行 1.7.0

Jenkins 的安装需要 Java8 或更高版本,但你正在运行 1.7.0

自从2017之后,Jenkins 放弃了对 Java 7 的支持,现在使用 Java 8。

我正在尝试在 Debian Jessie(docker 容器)上安装 Jenkins,我正在使用通过此获得的以下步骤关联

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

在该过程的最后一步,发生了以下情况:

$ apt-get install jenkins
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have 
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 jenkins : Depends: default-jre-headless (>= 2:1.8) but 2:1.7-52 is to be installed or
                java8-runtime-headless but it is not installable
E: Unable to correct problems, you have held broken packages.

我找到了解决方案这里

$ apt install -t jessie-backports  openjdk-8-jre-headless ca-certificates-java

无论如何,我设法安装了 Jenkins,但是当启动 Jenkins 时,发生了以下情况:

$ sudo /etc/init.d/jenkins start
[FAIL] Starting Jenkins Automation Server: jenkins failed!


$ tail -f /var/log/jenkins/jenkins.log 
Jenkins requires Java8 or later, but you are running 1.7.0_151-b01
from /usr/lib/jvm/java-7-openjdk-amd64/jre
  java.lang.UnsupportedClassVersionError: 51.0
    at Main.main(Main.java:124)

例如,我是否必须将 Java 8 安装到 Debian Jessie?

答案1

我发现有些 JRE 包引起了冲突。

前:

$ sudo dpkg -l | grep --color 'java\|jdk\|jre'
ii  ca-certificates-java          20161107~bpo8+1            all          Common CA certificates (JKS keystore)
ii  default-jre-headless          2:1.7-52                   amd64        Standard Java or Java compatible Runtime (headless)
ii  java-common                   0.52                       all          Base of all Java packages
ii  libatk-wrapper-java           0.30.5-1                   all          ATK implementation for Java using JNI
ii  libatk-wrapper-java-jni:amd64 0.30.5-1                   amd64        ATK implementation for Java using JNI (JNI bindings)
ii  openjdk-7-jre:amd64           7u151-2.6.11-2~deb8u1      amd64        OpenJDK Java runtime, using Hotspot JIT
pi  openjdk-7-jre-headless:amd64  7u151-2.6.11-2~deb8u1      amd64        OpenJDK Java runtime, using Hotspot JIT (headless)
ii  openjdk-8-jre-headless:amd64  8u131-b11-1~bpo8+1         amd64        OpenJDK Java runtime, using Hotspot JIT (headless)
ii  tzdata-java                   2017c-0+deb8u1             all          time zone and daylight-saving time data for use by java runtimes

删除软件包:

$ sudo dpkg -P openjdk-7-jre:amd64
(Reading database ... 15248 files and directories currently installed.)
Removing openjdk-7-jre:amd64 (7u151-2.6.11-2~deb8u1) ...
Processing triggers for hicolor-icon-theme (0.13-1) ...

$ sudo dpkg -P openjdk-7-jre-headless:amd64
(Reading database ... 15222 files and directories currently installed.)
Removing openjdk-7-jre-headless:amd64 (7u151-2.6.11-2~deb8u1) ...
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/pack200 to provide /usr/bin/pack200 (pack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/unpack200 to provide /usr/bin/unpack200 (unpack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/orbd to provide /usr/bin/orbd (orbd) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/servertool to provide /usr/bin/servertool (servertool) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/tnameserv to provide /usr/bin/tnameserv (tnameserv) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode
Purging configuration files for openjdk-7-jre-headless:amd64 (7u151-2.6.11-2~deb8u1) ...

后:

$ dpkg -l | grep --color 'java\|jdk\|jre'
ii  ca-certificates-java          20161107~bpo8+1            all          Common CA certificates (JKS keystore)
ii  java-common                   0.52                       all          Base of all Java packages
ii  libatk-wrapper-java           0.30.5-1                   all          ATK implementation for Java using JNI
ii  libatk-wrapper-java-jni:amd64 0.30.5-1                   amd64        ATK implementation for Java using JNI (JNI bindings)
ii  openjdk-8-jre-headless:amd64  8u131-b11-1~bpo8+1         amd64        OpenJDK Java runtime, using Hotspot JIT (headless)
ii  tzdata-java                   2017c-0+deb8u1             all          time zone and daylight-saving time data for use by java runtimes

启动 Jenkins:

$ /etc/init.d/jenkins start
[ ok ] Starting Jenkins Automation Server: jenkins.
$ tail -f /var/log/jenkins/jenkins.log 
Jan 19, 2018 1:22:39 PM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
Jan 19, 2018 1:22:41 PM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tools.JDKInstaller
Jan 19, 2018 1:22:41 PM hudson.model.AsyncPeriodicWork$1 run
INFO: Finished Download metadata. 9,126 ms
Jan 19, 2018 1:22:43 PM hudson.model.UpdateSite updateData
INFO: Obtained the latest update center data file for UpdateSource default
Jan 19, 2018 1:22:43 PM hudson.WebAppMain$3 run
INFO: Jenkins is fully up and running

加:

默认情况下,Jenkins 通过 localhost(端口 8080)。

用户:行政

密码:猫/ var / lib /詹金斯/机密/初始管理员密码

相关内容