Java

安裝 Jenkins 需要 Java8 或更高版本,但您執行的是 1.7.0

  • May 9, 2018

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?

我發現有導致衝突的 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

啟動詹金斯:

$ /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 通過本地主機(埠 8080)。

**使用者:**管理員

密碼: cat /var/lib/jenkins/secrets/initialAdminPassword

引用自:https://serverfault.com/questions/893118