解决jenkins执行bash shell脚本中途指令报错却仍然继续执行后面指令问题

在脚本开始处添加set -e

参考脚本如下:

#!/bin/bash

# 打开错误推出开关
set -e

# 加载环境变量
source /etc/profile

mvn clean compile -T8

# fabric部署脚本
fab -f xx.py deploy

说明:

在这种模式下,脚本运行的任何返回非零exitcode(shell世界中的一个错误)的命令都会导致脚本本身立即终止,并出现错误。

发布了161 篇原创文章 · 获赞 39 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/hknaruto/article/details/102500118