1

我试图编写一个取决于 cccheckout 命令成功或失败的逻辑。是否有类似于 exec 任务中的 returnProperty 属性的东西?

谢谢, 阿尔西

4

2 回答 2

0

Looking at the CCCheckout documentation, I would rather use the exception mechanism to process any failure.

failonerr

Throw an exception if the command fails. Default is true. Since ant 1.6.1

In ant, that means you can separate your ant process in two (one if no failure, one one exception), using the ant trycatch task.

于 2012-07-04T13:24:37.393 回答
0

您可能会问这个问题,因为 cleartool.exe
有时会表现得很奇怪,这意味着即使没有发生真正的错误,它也会返回 RC -1。
使用cccheckoutwith 的failonerr="true"方法有时会导致不必要Build failed
的操作,因为任何 RC != 0 都会被 exec 任务作为错误处理。
但是您可以<exec>直接将任务与可执行的 cleartool.exe 一起使用并设置属性

  • resultproperty 使 RC 可用作属性
  • outputproperty 使标准输出可用作属性
  • errorproperty 使 stderr 可用作属性

用于进一步处理,即使用条件任务来检查这些属性..
Ant 插件提供的一些 try/catch/finally 功能,例如:

正如 VonC 已经提到的那样,可能会派上用场。
如果之后变得更复杂,请使用Groovy ant 任务或脚本任务。

于 2012-07-05T07:14:01.313 回答