Ubuntu 安装Jenkins报错
背景信息在Uubunt中已安装了jdk,并在~/.cshrc和/etc/profile文件中都设置了JDK的家目录,然后使用apt-get install jenkins命令安装jenkins时报错如下所示:Reading state information... Donejenkins is already the newest version (2.107.3).0 upgraded, 0..
·
背景信息
在Uubunt中已安装了jdk,并在~/.cshrc和/etc/profile文件中都设置了JDK的家目录,然后使用apt-get install jenkins命令安装jenkins时报错如下所示:
Reading state information... Done
jenkins is already the newest version (2.107.3).
0 upgraded, 0 newly installed, 0 to remove and 414 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up jenkins (2.107.3) ...
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; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2018-05-14 05:47:25 PDT; 6ms ago
Docs: man:systemd-sysv-generator(8)
Process: 2990 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)
May 14 05:47:25 ubuntu systemd[1]: Starting LSB: Start Jenkins at boot time...
May 14 05:47:25 ubuntu jenkins[2990]: ERROR: No Java executable found in current PATH: /bin:/usr/bin:/sbin:/usr/sbin
May 14 05:47:25 ubuntu jenkins[2990]: If you actually have java installed on the system make sure the executable is in the aforementioned path and that 'type...utable path
May 14 05:47:25 ubuntu systemd[1]: jenkins.service: Control process exited, code=exited status=1
May 14 05:47:25 ubuntu systemd[1]: Failed to start LSB: Start Jenkins at boot time.
May 14 05:47:25 ubuntu systemd[1]: jenkins.service: Unit entered failed state.
May 14 05:47:25 ubuntu systemd[1]: jenkins.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package jenkins (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
原因分析
从如下报错信息可以看出主要是找不到jdk的bin文件
ERROR: No Java executable found in current PATH: /bin:/usr/bin:/sbin:/usr/sbin
查看环境变量:可以看到是有jdk的,排除环境变量设置问题
root@ubuntu:~# echo $PATH
/usr/jdk1.8.0_131/bin:/usr/jdk1.8.0_131/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
解决办法
创建一条软链接,如下所示
ln -s /usr/jdk1.8.0_131/bin/java /usr/bin/java
附录
环境变量的配置如下:
vi ~/.bashrc
export JAVA_HOME=/usr/jdk1.8.0_131
export JRE_HOME=${JAVA_HOME}/jre
export PATH=${JAVA_HOME}/bin:${PATH}
export CLASSPATH=.:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jart
更多推荐
已为社区贡献9条内容
所有评论(0)