我在 Jenkins Ant 执行插件中有一个 Ant 任务,作为构建后步骤,用于在我们的一台服务器中远程运行 shell 脚本。shell 脚本在后台启动一个 java 进程。当我直接在服务器上执行 shell 脚本时,它会在后台启动 java 进程并出来。当我通过sshexec任务从 Jenkins 运行它时,shell 脚本会运行,但它永远不会出现,Jenkins Build 会等待。
后来,当我将timeout属性添加到sshexec它时,它在给定的毫秒数后超时,但 Jenkins 构建显示为失败。如何使 sshexec 任务从 shell 脚本执行中干净利落地出来?
这是我的ssheexec任务
<sshexec host="${deploy.host}" username="${deploy.username}" password="${deploy.password}" command=". /etc/profile; cd ${deploy.path}; sh start.sh i1" trust="true" timeout="10000" />
start.sh文件如下所示:
nohup java -Xms512m -Xmx1024m -cp calculation.jar com.tes.StartCalculation $1 &
echo $! > calculation-$1-java.pid