第一個問題 : /var/jenkins_home/.ssh/known_hosts No Known
第二個問題:jenkins Slave JVM has terminated. Exit code=126
First :原因:jenkins master 通過ssh登錄slave失敗
背景:已經安全ant
,配置java
環境OK
仔細看日誌,發現錯誤信息: /var/jenkins_home/.ssh/known_hosts [SSH] No Known Hosts file was found at /var/jenkins_home/.ssh/known_hosts. Please ensure one is created at this path and that Jenkins can read it.
Jenkins用戶下,操作如下:
64 ssh-keygen
65 cd .ssh
69 cat id_rsa.pub > authorized_keys
70 chmod 700 authorized_keys
Jenkins master Web界面操作:
step 1
選項:Host Key Verification Strategy (主機密鑰驗證策略)修改;ssh 連接默認22;如果修改port點擊高級
"Known Hosts file verification strategy" 更改爲 "Manually trusted key verification strategy".
CONFIGURE AGENT -> LAUNCH METHOD -> Manually trusted key verification strategy - > SAVE.
step 2
遠程工作目錄 ,配置爲 /root/.jenkins
,此處配置爲了讓master能找到slave的.ssh
目錄。
至此,問題解決。
---------------------------------------------------------------------------
第二個問題:出現現象
jenkins slave啓動報錯:hudson.util.IOException2: Slave JVM has terminated. Exit code=126
正常的配置如下
分析下圖原因:
因爲java-path(JDK路徑) ,這個報錯就是由於路徑設置(沒精確到java指令)錯誤的填寫。此處java路徑 不能僅僅指定JAVA_HOME
還要精確到java指令位置。如果只是到JAVA_HOME就會出現 bash: /usr/java/jdk1.8.0_101: is a directory
Click the Advanced button under the Launch Method section of the slave configuration and make sure JavaPath is set to /usr/java/jdk1.6.0_29/bin/java. It has to be the full path to the executable, not the JAVA_HOME location.如圖示我從節點的jdk配置
[root@test-prod-01 /usr/local]$ echo $JAVA_HOME
/usr/local/jdk/jdk1.8.0_171
[root@test-prod-01 /usr/local]$ cd /usr/local/jdk/jdk1.8.0_171/bin/
附上報錯日誌:
添加mac slave節點報錯如下:
Expanded the channel window size to 4MB
[18/09/15 19:11:54] [SSH] Starting slave process: cd "/test/app/abc/slavetest" && /usr/java /jdk1.8.0_101 -XX:MaxPermSize=2048m -Xmx2048m -jar slave.jar
bash: /usr/java/jdk1.8.0_101: is a directory
hudson.util.IOException2: Slave JVM has terminated. Exit code=126
at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:953)
at hudson.plugins.sshslaves.SSHLauncher.access$400(SSHLauncher.java:133)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:711)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException: unexpected stream termination
at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:200)
at hudson.remoting.Channel.<init>(Channel.java:419)
at hudson.remoting.Channel.<init>(Channel.java:398)
at hudson.remoting.Channel.<init>(Channel.java:394)
at hudson.remoting.Channel.<init>(Channel.java:383)
at hudson.remoting.Channel.<init>(Channel.java:375)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:344)
at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:945)
... 7 more
[18/09/15 19:11:54] Launch failed - cleaning up connection
[18/09/15 19:11:54] [SSH] Connection closed.
java路徑指定好之後;問題完美解決如圖
ps:參考文章https://stackoverflow.com/questions/26808494/jenkins-ssh-slave-configuration