aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Cruise control giving wrong status in email. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Cruise control giving wrong status in email." Watch "Cruise control giving wrong status in email." New topic
Author

Cruise control giving wrong status in email.

Roshan Kurian
Greenhorn

Joined: Dec 20, 2006
Posts: 3
Hi,

I am using cruise control for my continuos builds. Here is my problem.
This is the content of the buildfile that gets called from config.xml of the cruise control.

<project name="projectNJ" default="build" basedir="F:\NJ4.5\projectNJdev">
<target name="build">

<cvs command="-q update -d -P -A -C -R"/>
<exec dir="." executable="cmd" os="Windows XP">
<arg line="/c buildall.bat RESET_DATABASE_BUILD RELEASE_BUILD"/>
</exec>
</target>
</project>


In my buildall.bat file I have calls to many xml files which needs to be executed.
e.g
oResetDatabaseLite
if "%RESET_DATABASE_BUILD%" == "true" goto doResetDatabase
echo dblite on EJBServer
call build.bat dblite >> %PROJ_DIR%/buildall.log
if errorlevel==1 goto BUILD_FAILED

:BUILD_SUCCESS
echo .
echo Build Successfully Completed
echo . >> %PROJ_DIR%/buildall.log
echo Build Successfully Completed >> %PROJ_DIR%/buildall.log
goto end

:BUILD_FAILED
echo .
echo Build Failed - See errors
echo . >> %PROJ_DIR%/buildall.log
echo Build Failed - See errors >> %PROJ_DIR%/buildall.log
goto end

:End
cd %PROJ_DIR%
echo .
echo Build Over
echo . >> %PROJ_DIR%/buildall.log
echo Build Over >> %PROJ_DIR%/buildall.log


Here even if "build.bat dblite" call fails, My cruise control sends out a mail saying that "the build is successful" . Can you please suggest me what is that I am doing wrong or how to make the cruise control give me the correct message.

Please help

- Roshan
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Cruise Control is ultimately just Ant, and Ant can be a little less than predictable when using exec tasks (not that they wont run, but that Ant might have no visibility their output, depending on what he executable does). My guess is that Cruise Control is successfully calling buildall.bat, which is successfully running your script though it is going to the BUILD_FAILED block. If you use a batch file to perform your build you will need to use the errorstr of the exec task to let Cruise Control find out that the build failed.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Paul Sturrock:
Cruise Control is ultimately just Ant


Sorry, no, not at all. The only connection between CC and Ant is that CC is able to call Ant to execute Ant scripts.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

My mistake. You are of course right Ilja - I shouldn't believe everything I read without checking! The problem should still be fixable by using the errorstr attribute though.
Roshan Kurian
Greenhorn

Joined: Dec 20, 2006
Posts: 3
Hi,

Thank you very much for the information But what happened is

I tried <exec dir="." executable="cmd" os="Windows XP" errorstr="Build Failed">

in my build file. But my build failed completly saying
--
The <exec> type doesn't support the "errorstr" attribute.
--

I couldn't put The exec part into my schedule of config.xml as it is having a reference as following

<ant anthome="F:\apache-ant-1.6.2"
buildfile="projectNJ.xml"
target="build"
uselogger="true"
usedebug="true"/>

which in turn had the reference to buildall.bat.(The code I am using for this is mentioned in my question which I posted in the beginning.)

-----

I have now added exit /b 1 as a part of my BUILD_FAILED. Can this abnormal exit on failure be used in CC in any way?

--------------------
:BUILD_FAILED
echo .
echo Build Failed - See errors
echo . >> %CURAM_DIR%/buildall.log
echo Build Failed - See errors >> %CURAM_DIR%/buildall.log
exit /b 1
goto end
--------------------

- Roshan
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


I tried <exec dir="." executable="cmd" os="Windows XP" errorstr="Build Failed">

in my build file.



I couldn't put The exec part into my schedule of config.xml as it is having a reference as following
<ant anthome="F:\apache-ant-1.6.2"
buildfile="projectNJ.xml"
target="build"
uselogger="true"
usedebug="true"/>


Now I'm confused. Are you executing this batch file form an Ant build file, or CruiseControl? CruseControl's documentation mention this attribute.
[ December 20, 2006: Message edited by: Paul Sturrock ]
Roshan Kurian
Greenhorn

Joined: Dec 20, 2006
Posts: 3
I am executing this batch file from an Ant build file which is being called from the schedule of config.xml of Cruise control.

Here is the schedule part code that i am using

<schedule interval="1">
<ant anthome="F:\apache-ant-1.6.2"
buildfile="projectNJ.xml"
target="build"
uselogger="true"
usedebug="true"/>
</schedule>


and the code inside the projectNJ.xml is as following

<project name="projectNJ" default="build" basedir="F:\NJ4.5\projectNJdev">
<target name="build">

<cvs command="-q update -d -P -A -C -R"/>
<exec dir="." executable="cmd" os="Windows XP">
<arg line="/c buildall.bat RESET_DATABASE_BUILD RELEASE_BUILD"/>
</exec>
</target>
</project>


I hope now my question is clear. Sorry for the confusion.

-Roshan
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Ah - so your problem is that Ant doesn't know that your batch file running the BUILD_FAILED block == the build failed, since all it cares about is that your batch file was run without error. So you need to manually find a way to let Ant know the result of the batch script. You might be able to do something with the Ant exec task's outputproperty attribute.
[ December 20, 2006: Message edited by: Paul Sturrock ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
The most elegant way would be to have the batch file exit with an exit code != 0. Don't know how to do that, tough - if it's possible at all. Perhaps the "exit" command accepts a parameter?

If you have are able to do that, you only need to add failonerror attribute to the Ant task.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cruise control giving wrong status in email.