如果一项任务失败,则继续执行 ant 脚本 [英] Continue executing ant script if one task fails

查看:34
本文介绍了如果一项任务失败,则继续执行 ant 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Ant 脚本,它运行测试然后将我的应用程序部署到 QA 服务器.为了部署应用程序,它首先调用 sun-appserv undeploy,出于各种原因,可能会或可能不会部署应用程序.如果未部署应用程序,则取消部署将失败并且整个脚本停止.

I have an Ant script which runs tests then deploys my application to a QA server. To deploy the application it first calls sun-appserv undeploy, for various reasons the application may or may not be deployed. If the application is not deployed then undeploy fails and the whole script halts.

有什么方法可以让我容忍一个任务失败,记录它,然后让脚本的其余部分运行?

Is there some way that I can tolerate a failure on one task, log it, and let the rest of the script run?

推荐答案

AntContrib try catch:

AntContrib try catch:

<trycatch>
<try>
   <!-- do deployment getting return code -->
</try>
<catch>
   <!-- echo the return code with a message -->
</catch>
</trycatch>

exec 任务有一个 failonerror 属性,您可以将其设置为 false 以继续执行.

The exec task has a failonerror attribute which you can set to false to keep going.

这篇关于如果一项任务失败,则继续执行 ant 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆