RTC build result exit code
I have tested the "command line" build definition with JBE and found the following fact:
1.RTC build definition excutes command: cmd /c a.bat
a.bat:
the build result is successful without error code massage
2.RTC build definition excutes command: cmd /c a.bat
a.bat:
test2.bat:
the build result is successful without error code massage
3.RTC build definition excutes command: cmd /c a.bat
a.bat:
test2.bat:
the build result is failed with "error code =1" massage
do you have any idea why these 3 conditions have different results?
and why in case 1, the "stop" still echo out after an exit command?
Thanks.
1.RTC build definition excutes command: cmd /c a.bat
a.bat:
echo start
cmd /c exit /b 1
echo stop
the build result is successful without error code massage
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>echo start
start
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>cmd /c exit /b 1
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>echo stop
stop
2.RTC build definition excutes command: cmd /c a.bat
a.bat:
echo start
test2
echo stop
test2.bat:
exit /b 1
the build result is successful without error code massage
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>echo start
start
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>test2
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>exit /b 1
3.RTC build definition excutes command: cmd /c a.bat
a.bat:
echo start
test2
echo stop
test2.bat:
cmd /c exit /b 1
the build result is failed with "error code =1" massage
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>echo start
start
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>test2
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>cmd /c exit /b 1
Build Failed, Exit code is 1
do you have any idea why these 3 conditions have different results?
and why in case 1, the "stop" still echo out after an exit command?
Thanks.
One answer
I have tested the "command line" build definition with JBE and found the following fact:
1.RTC build definition excutes command: cmd /c a.bat
a.bat:
echo start
cmd /c exit /b 1
echo stop
the build result is successful without error code massage
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>echo start
start
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>cmd /c exit /b 1
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>echo stop
stop
2.RTC build definition excutes command: cmd /c a.bat
a.bat:
echo start
test2
echo stop
test2.bat:
exit /b 1
the build result is successful without error code massage
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>echo start
start
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>test2
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>exit /b 1
3.RTC build definition excutes command: cmd /c a.bat
a.bat:
echo start
test2
echo stop
test2.bat:
cmd /c exit /b 1
the build result is failed with "error code =1" massage
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>echo start
start
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>test2
C:\IBM\JAZZ\maven\apache-maven-2.2.1-bin\bin\my-app>cmd /c exit /b 1
Build Failed, Exit code is 1
do you have any idea why these 3 conditions have different results?
and why in case 1, the "stop" still echo out after an exit command?
Thanks.
Hi,
The various outcomes are a result of Windows behavior. You can get the same results by just executing the batch files shown in a Windows command window instead of running through a build.
There are a few Windows documentation pages that help explain the behavior.
cmd
exit
call
A couple of things I noticed in the examples. The exit code can be checked by echoing the ERRORLEVEL. I believe that you may have wanted to use a 'call' statement in your a.bat files to call the test2.bat instead of directly invoking it.
Brent Ulbricht
RTC Build Lead