I have a piece of code in my ant build.xml
<retry retrycount="10" retrydelay="30000">
<exec executable="${env.M2_HOME}/bin/mvn.cmd" output="@{log}" failonerror="true" resultproperty="res" timeout="@{timeoutmillis}" errorproperty="error">
...
</exec>
</retry>
<echo message="${res}"/>
I retry my cmd task if if fails once upto 10 times. But even if it were to succeed after retrying a few turns, the value returned in res is 1 even though it is a build success. I expect it to be 0 as if it was SUCCESS.
Properties in Ant are immutable (they're not variables), so even if your
exectask eventually succeeds, the result property will have already been set to whatever it got from the first run.You can get past this by creating a
sequentialblock and using thelocaltask inside it to control your property scope.Running the above example will prompt the user until "n" is provided as input (or 10 retries).