我知道,这是一个非常古老的线程,但也许它会被其他人完全使用。您可以使用 try->catch 语句来实现解决方案。我的例子:
<trycatch>
<try>
<exec
command="${progs.mysql} -h${db.live.host} -u${db.live.user} -p${db.live.password} ${db.live.name} < ${db.live.output}/${build.dbdeploy.deployfile}"
dir="${project.basedir}"
checkreturn="true" />
<echo>Live database was upgraded successfully</echo>
</try>
<catch>
<echo>Errors in upgrading database</echo>
<exec
command="${progs.mysql} -h${db.live.host} -u${db.live.user} -p${db.live.password} ${db.live.name} < ${db.live.output}/${build.dbdeploy.undofile}"
dir="${project.basedir}"
checkreturn="true" />
</catch>
</trycatch>