ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Reeves" <CRee...@medfusion.net>
Subject RE: Emailing Build results
Date Tue, 04 Mar 2003 21:09:53 GMT
I use a slightly different approach to have the buld results sent.

First, I created a second, separate ant build script that wraps my
build.xml file.

This second script checks the project out of cvs, then executes the
build.xml present at the root of the project. When the ant call
completes, the log file is attached to a mail message. This occurs even
if the wrapped build fails.

I'm sure there's a cleaner way to do this, but it has run for months
with no problems.

Additionally, it's great to see the "Failed" or "Succeeded" on the
subject line, so I don't have to open each message and scour the logs
just to discover the build succeeded.

Chris


...

<snip>


	  <!--
========================================================================
======== -->
        <!-- Target: build_project -->
        <!--
========================================================================
======== -->

        <target name="build_project" depends="init, clean,
cvs_checkout">

                <echo message="Executing ant file
${project.root.dir}/${project.antfile}"/>

                <exec   dir             = "${project.root.dir}"
                        executable      = "/usr/java/ant/bin/ant"
                        output          =
"${log.dir}/nightly_build_results_${filename.suffix}.txt"
                        resultproperty  = "project.build.result"
                        outputproperty  = "project.build.output">
                        <arg line       = "${project.anttarget}"/>
                </exec>

                <echo message="Done."/>

        </target>


        <!--
========================================================================
======== -->
        <!-- Target: send_notification -->
        <!--
========================================================================
======== -->

        <target name="send_notification" depends="init, build_project">

                <condition property="build.result" value="Failed!!!">
                        <equals arg1="1"
arg2="${project.build.result}"/>
                </condition>

                <condition property="build.result" value="Succeeded!!!">
                        <equals arg1="0"
arg2="${project.build.result}"/>
                </condition>

                <mail   tolist                  = "${to.address}"
                        from                    = "${from.address}"
                        subject                 = "${build.result}
${project.longname} Nightly Build - ${build.time}"
                        mailhost                = "${smtp.server}"
                        messagefile             =
"${log.dir}/nightly_build_results_${filename.suffix}.txt">
                </mail>

        </target>

</snip>

...

> -----Original Message-----
> From: Alexei Betin [mailto:ABetin@futuretrade.com] 
> Sent: Tuesday, March 04, 2003 4:01 PM
> To: Ant Users List
> Subject: Emailing Build results
> 
> 
> what are reasonable options for emailing nightly Build results?
> 
> MailLogger seems to have no way to attach the build log
> or use properties in Subject, 
> 
> also I am already using NoBannerLogger - which leaves no 
> place for MailLogger...
> 
> <mail> task cannot help me, because if I put it at the end
> of my build script, and the build fails, it'll never get to 
> execute it. 
> 
> Is there a way to ensure a task is always called at the end? 
> maybe using different build files with <ant> or <antcall>? 
> <parallel> would not help me here because it can only wrap 
> tasks and not targets...
> 
> Finally, I understand I can write my own Logger,
> but for a couple of reasons I don't want to - I would
> rather prefer to get the job done by some batch file,
> but I wonder if I am missing a nice pure-Ant solution
> 
> Thanks,
> ~Alexei
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 

Mime
View raw message