之前的几台Jenkins Slave 都是OK的,最近新加一台,却在连接Slave时有下列没有JDK 环境呢
Linux xmicnis 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Installing JDK jdk-6u16-oth-JPR@CDS-CDS_Developer
Downloading JDK from http://download.oracle.com/otn/java/jdk/6u16-b01/jdk-6u16-linux-x64.bin
Oracle now requires Oracle account to download previous versions of JDK. Please specify your Oracle account username/password.
hudson.util.IOException2: Could not find any known supported java version in [java, /usr/bin/java, /usr/java/default/bin/java, /usr/java/latest/bin/java, /usr/local/bin/java, /usr/local/java/bin/java, /Dailybuild/Dailybuilds/jdk/bin/java], and we also failed to install JDK as a fallback
at hudson.plugins.sshslaves.SSHLauncher.resolveJava(SSHLauncher.java:657)
at hudson.plugins.sshslaves.SSHLauncher.launch(SSHLauncher.java:593)
at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:243)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:701)
Caused by: hudson.AbortException: Unable to install JDK unless a valid Oracle account username/password is provided in the system configuration.
at hudson.tools.JDKInstaller.locate(JDKInstaller.java:426)
at hudson.plugins.sshslaves.SSHLauncher.attemptToInstallJDK(SSHLauncher.java:764)
at hudson.plugins.sshslaves.SSHLauncher.resolveJava(SSHLauncher.java:655)
... 8 more
[04/29/15 09:06:16] [SSH] Connection closed.
很奇怪,系统中安装了JDK了,为什么会有这样的问题呢。远程登录服务器 查看了一下
java -versionj<span style="white-space:pre"> </span><span style="font-family: Arial, Helvetica, sans-serif;">J</span><span style="font-family: Arial, Helvetica, sans-serif;">ava version "1.7.0_75" </span><span style="font-family: Arial, Helvetica, sans-serif;">Java(TM) SE Runtime Environment (build 1.7.0_75-b13)<span style="white-space:pre"> </span> </span><span style="font-family: Arial, Helvetica, sans-serif;">Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)</span>
可是这就奇怪,换了个账号试试
java version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
两个账号下jdk 环境部一样,想起来了当时这台服务器为了兼容不同平台的编译,在装JDK 时用了sun jdk1.6 和OPEN JDK 1.7,但是都是手动解压包,没有做链接。因为我当时自己加了两个JDK系统环境变量在/etc/profile.d/jdk.sh,通过运行函数来设置当前环境变量镇南关的JDK,感兴趣可以参考《/etc/profile.d下添加环境变量》。
正常的情况下用apt-get 安装完jdk 后会生成以下链接
/usr/bin/java -> /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
或者在有多个java 版本的情况下可以使用设置alternatives java 来更改java版本
update-alternatives --config java
解决方法:
尝试在~/.profile和~/.bashrc中加入环境变量,都失败,因为加载这里是需要用户登录才可以的。
好在Jenkins 通过环境变量设置: