Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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:
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.

0 votes



One answer

Permanent link
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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Aug 08 '11, 8:40 p.m.

Question was seen: 4,507 times

Last updated: Aug 08 '11, 8:40 p.m.

Confirmation Cancel Confirm