It's all about the answers!

Ask a question

RTC build result exit code


Hsuan-Po Lin (1143) | asked Aug 08 '11, 8:40 p.m.
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.

One answer



permanent link
Brent Ulbricht (2.5k11) | answered Aug 13 '11, 3:54 p.m.
JAZZ DEVELOPER
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

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.