解决:ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [-1]]

来源:互联网 发布:政府机构邮箱搜索软件 编辑:程序博客网 时间:2024/04/30 12:21

问题:今天Jenkins使用Publish Over SSH Plugin遇到一个问题:错误如下

SSH: Connecting from host [localhost.localdomain]SSH: Connecting with configuration [47.94.8.78] ...SSH: EXEC: STDOUT/STDERR from command [rm -rf /var/tmp/garage/server/centerunzip -oq /var/tmp/remote-deploy/garage-dacheng-server.war -d /var/tmp/garage/server/centerps -ef |grep tomcat-center |awk '{print $2}'|xargs kill -9  1>/dev/null 2>&1 | exit 0service tomcat-center start] ...SSH: EXEC: completed after 1,007 msSSH: Disconnecting configuration [47.94.8.78] ...ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [-1]]Build step 'Send build artifacts over SSH' changed build result to UNSTABLEFinished: UNSTABLE
“Exec exit status not zero” 说明进程没有正常结束,经过排除,问题锁定在:
ps -ef |grep tomcat-center |awk '{print $2}'|xargs kill -9  1>/dev/null 2>&1 | exit 0

分析:

ps -ef | grep tomcat-center 查询到的是两条记录(如下图):第一条是我们要查找并关闭的,第二条是查找进程自身。

当管道进行到kill的时候,两条进程一同被杀死,而Jenkins仍然在等待查找进程自身返回exit 0,事实上它永远等不到了,因为进程都没了,

最终会报异常"Exec exit status not zero"

解决:

使用“grep -v grep”排除掉它自身就可以

原来:ps -ef |grep tomcat-center |awk '{print $2}'|xargs kill -9

改后:ps -ef |grep tomcat-center | grep -v grep |awk '{print $2}'|xargs kill -9





阅读全文
1 0
原创粉丝点击