本文介绍了从shell脚本执行maven任务,并得到错误codeS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我执行一个Maven但是即使Maven的任务失败,该脚本将继续并完成,没有错误部署从bash脚本任务。

I'm executing a Maven deploy task from a bash script however even if the Maven task fails the script will continue and complete without errors.

我已经试过了-e标志,但导致部署失败。我也试过以下(伪code)

I have tried the -e flag but that causes the deploy to fail. I also tried the following (pseudo code)

result_code= mvn deploy
if [$result_code -gt 0];then
exit 1

任何建议,我怎么能确定是否部署成功?

Any suggestions how i can identify if the deploy was successful?

推荐答案

result_ code = MVN部署不是为了返回状态的方式。

result_code=mvn deploy is not the way to get return status

您可以尝试例如

#!/bin/bash
mvn deploy
STATUS=$?
if [ $STATUS -eq 0 ]; then
echo "Deployment Successful"
else
echo "Deployment Failed"
fi

这篇关于从shell脚本执行maven任务,并得到错误codeS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 05:29