CruiseControl.NET & batch's %ERRORLEVEL%
I wanted to do a very simple thing using CruiseControl.NET - have a batch file that does some work be executed in my project and if error level is not "0" fail the test.
<project name="HUB" queue="SR_GUI">
<sourcecontrol type="nullSourceControl" />
<projectTrigger project="SP Build" />
<exec executable="BuildHub.bat" />
The batch looks something like this:
echo provision drive
... some lines script ...
Echo Debug: Error level = %ERRORLEVEL%
I started to check the project by running it and although I knew it should fail (I saw the debug note about error level = 9002) it always reported as succeeded.
initially I tough that because I used last action of echo then it might reset the error level but this wasn't the case (validated by running manually)
To make a long story short the resolution was to simply put the following line at the end of the batch:
Exit /B %ERRORLEVEL%
As always I hope this save you some time