Hi,

I would recommend to use "exit 1" instead of "exit /b 1".
That should always work.

"exit /b 1" means "exit batch with error code 1" and is supposed to be used
when calling a bat file from another bat file.
Then you can check "errorlevel" for the result.

"exit 1" means "exit process with exit code 1", and is safer to use when
called from a windows application such as CC.NET.

If you e.g. call the bat file by calling "cmd.exe /C <file>", then the
cmd.exe will still exit with code 0.

The disadvantage with "exit 1" is of course that if you call the bat file
manually from a command prompt, then the command prompt will also exit.
You could then change your bat file to the following to support both CC.Net
and manual execution:
if defined CCNetProject exit 1
exit /b 1

//P-J

2009/3/24 Ruben Willems <[email protected]>

> Hi
>
> I'll check this, ...
>
>
> with kind regards
> Ruben Willems
>
> On Tue, Mar 24, 2009 at 10:35 AM, Michal Dabrowski <
> [email protected]> wrote:
>
>>
>> Hi
>>
>> Thanks for your answer. I've just performed very similar test, but
>> with bat file instead of an exe. The batch consists solely of the
>> following line:
>>
>> exit /b 1
>>
>> I've configured the cc.net to execute this script as the first
>> prebuild task with:
>>
>>  <prebuild>
>>    <exec>
>>      <executable>d:\michald\scr.bat</executable>
>>    </exec>
>>    ...................
>>  </prebuild>
>>
>> And the cc.net just ignores this error and proceeds with next tasks. I
>> can only add that before upgrade to 1.4.3 this worked as expected, ie.
>> the builds were reported as broken.
>>
>> Does anyone experience similar problem?
>>
>> Regards,
>> Michal Dabrowski
>>
>> On Mar 19, 3:18 pm, Ruben Willems <[email protected]> wrote:
>> > Hi
>> >
>> > CCNet's exec task is ok, I just tested it again
>> > with the following test programs (2 console programs):
>> >
>> > consok
>> > code in the main
>> >    Environment.ExitCode == 0;
>> >
>> > consNotOk
>> > code in the main
>> >    Environment.ExitCode == 1;
>> >
>> > and when I placed these in CCNet, the build was OK for consok
>> > and the build failed for consNotOk
>> >
>> > So there must be a problem with your config, or the tasks really fail
>> >
>> > with kind regards
>> > Ruben Willems
>> >
>> > On Thu, Mar 19, 2009 at 2:32 PM, Michal Dabrowski <
>> >
>> > [email protected]> wrote:
>> >
>> > > Hi,
>> >
>> > > yesterday I've updated my CCNet to 1.4.3. Today I've noticed that
>> > > CCNet no longer recognizes failures of exec tasks. This actually
>> > > applies to <exec> and <rake> tasks. Every build is successful, even if
>> > > the rake aborts or the exec tasks fail. Most of my CCNet configuration
>> > > remained the same as before the upgrade (after upgrade I've only
>> > > replaced msbuild with rake, but these mentioned exec tasks weren't
>> > > touched at all). Did anyone else encounter such behavior?
>> >
>> > > Regards,
>> > > Michal Dabrowski
>>
>
>

Reply via email to