I am calling a batch file using an Ant exec task and setting the result in resultpropery. But the return value never comes to Ant. Below is my code
<property name="BuildErrorCode" value="abc"/>
<exec executable="cmd" resultproperty="BuildErrorCode" failonerror="false"
dir="C:\workspace\build\">
<arg value="/c"/>
<arg value="cmake_cross_compile.bat"/>
</exec>
<echo message="Error Code:=${BuildErrorCode}" />
I exit my batch script by:
if %errorlevel% neq 0 exit /b %errorlevel%
When the script runs, i always get abc as value instead of return value from batch file. My batch file returns 2 for now and I have to stop the build
I want to do the following:
- If the return value is <> 0 then i have to make the build fail which is not happening now.
Any idea how I can get he return value and make the ant build fail?