在Java 11下运行Jenkins

时间:2018-11-15 14:50:14

标签: java ubuntu jenkins

试图从Java 8升级到11,但是Jenkins不能在11以下运行。每周的实验版本说它们可以在Java 10上运行,所以我想,我会帮助他们进行测试。

所以我升级到jenkins_2.151_all.deb(在我的Ubuntu盒子上),但是现在我继续收到此错误消息:

thomas@testbox:~$ systemctl status jenkins.service
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-11-15 14:12:46 UTC; 6s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8127 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILU

Nov 15 14:12:46 testbox jenkins[8127]: Found an incorrect Java version
Nov 15 14:12:46 testbox jenkins[8127]: Java version found:
Nov 15 14:12:46 testbox jenkins[8127]: java version "11" 2018-09-25
Nov 15 14:12:46 testbox jenkins[8127]: Java(TM) SE Runtime Environment 18.9 (bui
Nov 15 14:12:46 testbox jenkins[8127]: Java HotSpot(TM) 64-Bit Server VM 18.9 (b
Nov 15 14:12:46 testbox jenkins[8127]: Aborting
Nov 15 14:12:46 testbox systemd[1]: jenkins.service: Control process exited, cod
Nov 15 14:12:46 testbox systemd[1]: Failed to start LSB: Start Jenkins at boot t
Nov 15 14:12:46 testbox systemd[1]: jenkins.service: Unit entered failed state.
Nov 15 14:12:46 testbox systemd[1]: jenkins.service: Failed with result 'exit-co

因此,我按照此处的指示进行操作:Jenkins fails when running "service start jenkins"在针对我的Java 11的最高排名答案上,我一直遇到相同的错误。

所以我想拧紧它。我将在java8实例下运行jenkins。因此,我更改了上面插入的路径,以针对/ opt / java8(我的Java安装位置)运行。我得到:

thomas@testbox:/opt$ systemctl status -l jenkins.service
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-11-15 14:15:50 UTC; 1min 3s
     Docs: man:systemd-sysv-generator(8)
  Process: 8237 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILU

Nov 15 14:15:50 testbox jenkins[8237]: Found an incorrect Java version
Nov 15 14:15:50 testbox jenkins[8237]: Java version found:
Nov 15 14:15:50 testbox jenkins[8237]: java version "1.8.0_101"
Nov 15 14:15:50 testbox jenkins[8237]: Java(TM) SE Runtime Environment (build 1.
Nov 15 14:15:50 testbox jenkins[8237]: Java HotSpot(TM) 64-Bit Server VM (build 
Nov 15 14:15:50 testbox jenkins[8237]: Aborting
Nov 15 14:15:50 testbox systemd[1]: jenkins.service: Control process exited, cod
Nov 15 14:15:50 testbox systemd[1]: Failed to start LSB: Start Jenkins at boot t
Nov 15 14:15:50 testbox systemd[1]: jenkins.service: Unit entered failed state.
Nov 15 14:15:50 testbox systemd[1]: jenkins.service: Failed with result 'exit-co

所以现在它甚至在抱怨Java 8。

不确定下一步如何尝试

3 个答案:

答案 0 :(得分:0)

sudo update-alternatives --config java 选择Java 8输入选择号,例如。 2 然后启动詹金斯(如果已经)

答案 1 :(得分:0)

更新

自版本 2.175 (于2019-04-28发行以来),詹金斯官方更改日志指出:

  

使Debian / Ubuntu启动器脚本与Java 11配合使用。(issue 57096

因此,在J11环境中启动/运行Jenkins应该使用Jenkins版本 2.175 或更高版本进行修复。您可以尝试一下。

希望有帮助。

答案 2 :(得分:0)

/etc/init.d/jenkins Java版本测试中,实际上看起来像是个问题。

执行systemctl status jenkins.service命令返回以下消息。

找到了错误的Java版本

找到Java版本:

openjdk版本“ 11.0.9.1” 2020-11-04

/etc/init.d/jenkins文件中,最后一行将JAVA_VERSION设置为11.09,与JAVA_ALLOWED_VERSION中的任何内容都不匹配。

要修复此问题,请更新/etc/init.d/jenkins文件中的许可sed行,并将其更改为:

JAVA_VERSION=$($JAVA -version 2>&1 | sed -n ';s/.* version "\([0-9]*\)\.\([0-9]*\)\..*".*/\1\2/p;')

参考:https://github.com/jenkinsci/packaging/pull/198