I have a batch file name xyz.bat with these content
@echo off
echo 1.Cleaning all four project.
call apacheant\bin\ant -buildfile clean-all.xml
When the first call end it write on console build succeed or build failed.
How do i verify that this call failed or passed moreover on this condition basis i want to decide the next call execution.
echo 1.Building all four project.
call apacheant\bin\ant -buildfile build-all.xml
@echo on
echo 1.Building all four project.
call apacheant\bin\ant -buildfile build-all.xml >logfile.txt
findstr "succeed" logfile.txt >nul
if errorlevel 1 (echo Build failed) else (echo Build Succeeded)
Naturally, the echo ...
could be replaced by 'set antstatus=SUCCEED` if required.
Don't try to use ERRORLEVEL to control the processing since MANY commands will change ERRORLEVEL to report their own status.
It may also be possible that ANT
returns a status on termination. You could check with
echo %errorlevel%
after the ant
step. If it returns an errorlevel, then you don't need to create and interpret the logfile.
The IF ERRORLEVEL
syntax is
if errorlevel n Command_if_errorlevel_is_n_OR_GREATER_THAN_n