我们在 Win 机器上运行 Jenkins 主服务器,并添加了 Mac OSX 从服务器,通过远程 Mac 上的 ssh 执行。众所周知,这种情况需要使用 启动从属命令java -Djava.awt.headless=true
,否则连接将使用 终止java.io.IOException: Unexpected termination of the channel
。尽管如此,我们仍然遇到此异常。奇怪的是,在恒定的时间段后不会抛出异常 - 在一个构建中,例如 30 分钟,在另一个构建中是 45 分钟。可能出了什么问题?
附加日志(IP 和 URL 被额外损坏)
[11/14/13 16:08:11] [SSH] Opening SSH connection to our.macos.machine:22.
[11/14/13 16:08:12] [SSH] Authentication successful.
[11/14/13 16:08:12] [SSH] The remote users environment is:
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_EXECUTION_STRING=set
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="48" [3]="1" [4]="release" [5]="x86_64-apple-darwin12")
BASH_VERSION='3.2.48(1)-release'
DIRSTACK=()
EUID=503
GROUPS=()
HOME=/Users/hudson
HOSTNAME=our.macos.machine
HOSTTYPE=x86_64
IFS=$' \t\n'
LOGNAME=hudson
MACHTYPE=x86_64-apple-darwin12
MAIL=/var/mail/hudson
OPTERR=1
OPTIND=1
OSTYPE=darwin12
PATH=/usr/bin:/bin:/usr/sbin:/sbin
PPID=93411
PS4='+ '
PWD=/Users/hudson
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=1
SSH_CLIENT='xxx.xxx.xxx.xxx 49852 22'
SSH_CONNECTION='xxx.xxx.xxx.xxx 49852 yyy.yyy.yyy.yyy 22'
TERM=dumb
TMPDIR=/var/folders/hg/298vj1kd4yj_f73tgbh6n0hr0000gq/T/
UID=503
USER=hudson
_=bash
[11/14/13 16:08:12] [SSH] Checking java version of java
[11/14/13 16:08:12] [SSH] java -version returned 1.7.0_40.
[11/14/13 16:08:12] [SSH] Starting sftp client.
[11/14/13 16:08:12] [SSH] Copying latest slave.jar...
[11/14/13 16:08:12] [SSH] Copied 346 309 bytes.
Expanded the channel window size to 4MB
[11/14/13 16:08:12] [SSH] Starting slave process: cd '/Users/hudson/build' && java -Djava.awt.headless=true -jar slave.jar
<===[JENKINS REMOTING CAPACITY]===>channel started
Slave.jar version: 2.32
This is a Unix slave
Evacuated stdout
Slave successfully connected and online
答案1
我遇到了同样的问题并在这里找到了解决方案:http://blog.narf.ssji.net/2012/11/fix_jenkins_unexpected_channel_termination
简而言之,我在 Node Setup > Launch Method > Advanced JVM Options 下添加了下面的一行:
-Djava.awt.headless=true
希望这可以帮助!