Starting Jenkins bash: /usr/bin/java: 没有那个文件或目录

 

 

[root@localhost /]# systemctl status jenkins.service
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since 六 2019-09-28 09:27:02 CST; 27min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 30069 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)

9月 28 09:27:02 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...
9月 28 09:27:02 localhost.localdomain runuser[30074]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
9月 28 09:27:02 localhost.localdomain jenkins[30069]: Starting Jenkins bash: /usr/bin/java: 没有那个文件或目录
9月 28 09:27:02 localhost.localdomain jenkins[30069]: [失败]
9月 28 09:27:02 localhost.localdomain systemd[1]: jenkins.service: control process exited, code=exited status=1
9月 28 09:27:02 localhost.localdomain systemd[1]: Failed to start LSB: Jenkins Automation Server.
9月 28 09:27:02 localhost.localdomain systemd[1]: Unit jenkins.service entered failed state.
9月 28 09:27:02 localhost.localdomain systemd[1]: jenkins.service failed.


[root@localhost /]# which java
/usr/local/iron/jdk1.8.0_191/bin/java

#JDK的安装路径和Jenkins 默认的JDK路径不一致
#建立软连接
ln -s /usr/local/iron/jdk1.8.0_191/jdk/bin/java /usr/bin/java

#如果多版本,可以使用下面的命令更新
[root@localhost /]# update-alternatives --install /usr/bin/java java /usr/local/iron/jdk1.8.0_191/bin/java 300
[root@localhost /]# update-alternatives --install /usr/bin/javac javac /usr/local/iron/jdk1.8.0_191/bin/javac 300
[root@localhost /]# update-alternatives --install /usr/bin/jar jar /usr/local/iron/jdk1.8.0_191/bin/jar 300
[root@localhost /]# update-alternatives --install /usr/bin/javah javah /usr/local/iron/jdk1.8.0_191/bin/javah 300
[root@localhost /]# update-alternatives --install /usr/bin/javap javap /usr/local/iron/jdk1.8.0_191/bin/javap 300
[root@localhost /]# update-alternatives --config java

[root@localhost /]# which java
/usr/bin/java

 


或者修改jenkins配置文件

vi /etc/rc.d/init.d/jenkins

类似如下修改:

candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/lib/jvm/java-11.0/bin/java
/usr/lib/jvm/jre-11.0/bin/java
/usr/lib/jvm/java-11-openjdk-amd64
/usr/bin/java
/usr/local/iron/jdk1.8.0_191/bin/java #把自己配置的目录加进去
"

 

posted @ 2019-09-28 10:11  VipSoft  阅读(1402)  评论(0编辑  收藏  举报