I using a Jenkins (on a windows machine) job to compile some code for different targets via Ant. For doing so, I wrap the call to the ant target within a (windows) batch loo
@echo off
for %%t in (target1 target2 target3) do (
ant -f build.xml build -DPARAM_TARGET=%%t
echo ELVL: %ERRORLEVEL%
IF NOT %ERRORLEVEL% == 0 (
echo ABORT: %ERRORLEVEL%
exit /b %ERRORLEVEL%
) ELSE (
echo PROCEED: %ERRORLEVEL%
)
)
IIRC The issue is that ant.bat is a batch file, so you need to call it, e.g.
@ECHO OFF
FOR %%t IN (target1 target2 target3) DO (
CALL ant.bat -f build.xml build -DPARAM_TARGET=%%t
ECHO ELVL: %ERRORLEVEL%
IF NOT %ERRORLEVEL% == 0 (
ECHO ABORT: %ERRORLEVEL%
EXIT /b %ERRORLEVEL%
) ELSE (
ECHO PROCEED: %ERRORLEVEL%
)
)
Update
Actually there is a nicer way:
@ECHO OFF
FOR %%t IN (target1 target2 target3) DO (
CALL ant.bat -f build.xml build -DPARAM_TARGET=%%t || EXIT /b 1
)