This is my automated build file (with some name alterations); it should point
you in the right direction. In our case, when the build succeeds we get a short
email pointing to simple logs, when it fails we get a huge email of a verbose
log of the build. The build runs 4 times a day, the huge(up to 16 MB) email
encourages the breaker of thee build to be a rapid fixer of the build :-)
Kevin Dickover
<?xml version="1.0"?>
<project name="MyProjectAutomatedBuild" default="BuildAll">
<description>Builds all MyProject Projects</description>
<property name="Base.Dir" value="C:\PROJECTHOME\" />
<property name="Log.Dir" value="${Base.Dir}Log\" />
<property name="nant.onsuccess" value="Success" />
<property name="nant.onfailure" value="Failure" />
<property name="tolist" value="[EMAIL PROTECTED]" />
<property name="cclist" value="" />
<mkdir dir="${Log.Dir}" failonerror="false" />
<tstamp property="Build.DateTime" pattern="yyyy-MM-dd.HHmm" verbose="true"/>
<property name="Build.Success.Log"
value="${Log.Dir}MyProjectAutomatedBuildSuccessLog-${Build.DateTime}.txt" />
<property name="Build.Failure.Log"
value="${Log.Dir}MyProjectAutomatedBuildFailureLog-${Build.DateTime}.txt" />
<property name="MyProjectExternal.TestReportName"
value="MyProjectExternalTestReport-${Build.DateTime}.xml" />
<property name="MyProjectExternal.TestReport"
value="${Log.Dir}${MyProjectExternal.TestReportName}" />
<property name="MyProjectExternal.LogDir"
value="C:\PROJECTHOME\MyProjectExternal\SomeDir\Log" />
<property name="AnotherProject.TestReportName"
value="AnotherProjectTestReport-${Build.DateTime}.xml" />
<property name="AnotherProject.TestReport"
value="${Log.Dir}${AnotherProject.TestReportName}" />
<property name="AnotherProject.LogDir"
value="C:\PROJECTHOME\AnotherProject\Log" />
<property name="YetAnotherProjectTestReportName"
value="tjxTestReport-${Build.DateTime}.xml" />
<property name="YetAnotherProjectTestReport"
value="${Log.Dir}${AnotherProject.TestReportName}" />
<property name="YetAnotherProjectLogDir" value="C:\PROJECTHOME\SomeDir\Log"
/>
<record name="${Build.Success.Log}" level="Info" action="Start" />
<record name="${Build.Failure.Log}" level="Verbose" action="Start" />
<target name="Success" depends="CloseLogs,MailSuccess" description="Closes
log Files and deletes failure log, runs unit tests and generates documentation.
This task is called as a result of nant.onsuccess and should not be called
independently.">
<delete file="${Build.Failure.Log}" />
</target>
<target name="Failure" depends="CloseLogs,MailFailure">
<delete file="${Build.Success.Log}" />
</target>
<target name="CloseLogs" description="Closes log files - do not call
independently" >
<record name="${Build.Success.Log}" action="Close" />
<record name="${Build.Failure.Log}" action="Close" />
</target>
<target name="MailSuccess" description="" >
<mail
from="[EMAIL PROTECTED]"
tolist="${tolist}"
cclist="${cclist}"
subject="MyProject Automated Build Succeded at ${Build.DateTime}"
message="See build Log located at
http://ASERVER/MyProjectBuildLogs/MyProjectAutomatedBuildSuccessLog-${Build.Date
Time}.txt. The MyProjectExternal TestReport is at http:// ASERVER
/MyProjectBuildLogs/${MyProjectExternal.TestReportName}. The AnotherProject
TestReport is at http:// ASERVER
/MyProjectBuildLogs/${AnotherProject.TestReportName}."
mailhost="smtp.server.com">
</mail>
</target>
<target name="MailFailure" description="" >
<mail
from="[EMAIL PROTECTED]"
tolist="${tolist}"
cclist="${cclist}"
subject="MyProject Automated Build Failed at ${Build.DateTime}"
mailhost="smtp.server.com">
<files>
<includes name="${Build.Failure.Log}" />
</files>
</mail>
</target>
<target name="BuildAll"
depends="BuildAnotherProject,BuildTJRecruiterWorkspace,BuildTJJobDistribution,Bu
ildtjx" description="Depnds on all other build tasks - runs a full build" />
<target name="BuildMyProjectExternal" description="Builds all
MyProjectExternal solutions" >
<delete dir="${Base.Dir}MyProjectExternal" failonerror="false" />
<nant buildfile="C:\PROJECTHOME\SomeDir\MyProject.build"
target="GetMyProjectExternal" />
<nant
buildfile="C:\PROJECTHOME\MyProjectExternal\SomeDir\MyProjectExternal.SomeDir.bu
ild" target="Debug" />
<exec program="C:\PROJECTHOME\SomeDir\Tools\NunitTestReportAggregator.exe"
commandline="${MyProjectExternal.LogDir} ${MyProjectExternal.TestReport}" />
</target>
<target name="BuildAnotherProject" description="Builds all AnotherProject
solutions" >
<delete dir="${Base.Dir}AnotherProject" failonerror="false" />
<nant buildfile="C:\PROJECTHOME\SomeDir\MyProject.build"
target="GetAnotherProject" />
<nant buildfile="C:\PROJECTHOME\AnotherProject\AnotherProject.build"
target="AnotherProject.Debug" />
<exec program="C:\PROJECTHOME\SomeDir\Tools\NunitTestReportAggregator.exe"
commandline="${AnotherProject.LogDir} ${AnotherProject.TestReport}" />
</target>
<target name="Buildtjx" description="Builds all tjx solutions" >
<delete dir="${Base.Dir}tjx" failonerror="false" />
<nant buildfile="C:\PROJECTHOME\SomeDir\MyProject.build" target="Gettjx" />
<exec program="cscript.exe"
commandline="C:\PROJECTHOME\SomeDir\YetAnotherProject.vbs" />
<nant buildfile="C:\PROJECTHOME\SomeDir\YetAnotherProjectbuild"
target="build.debug" />
<exec program="C:\PROJECTHOME\SomeDir\Tools\NunitTestReportAggregator.exe"
commandline="${YetAnotherProjectLogDir} ${YetAnotherProjectTestReport}" />
</target>
</project>
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Darrel Herbst
Sent: Wednesday, March 17, 2004 9:34 AM
To: [EMAIL PROTECTED]
Subject: [Nant-users] How do you mail the build log on failure?
I would like to set up a nightly build/test file which will email out the
build log if the build fails, but I keep getting this message below, which
looks to me as though the build log file is locked, so nant cannot read in
the file while it is writing it at the same time. How do other people mail
out the build log when their build breaks?
Thanks in advance for your help.
build_failed:
[mail] File 'C:\dherbst\src\Build\nightly.txt' NOT added to
message body. File does not exist or cannot be accessed.
[mail] Sending mail to [EMAIL PROTECTED]
BUILD FAILED
C:\dherbst\src\Build\nightly.build(639,7):
External Program Failed: C:\WINNT\Microsoft.NET\Framework\v1.1.4322\vbc.exe
(ret
urn code was 1)
Total time: 32 seconds.
I have a windows task set up to do our build and test runs at 4am, it runs
the nightly.bat script below:
echo Starting the nightly build
echo .
del nightly.txt
echo .
C:\dherbst\bin\nant\bin\NAnt.exe -logfile:nightly.txt
In the nightly.build script I have the following:
<!-- Set the onFailure property so you get the emails out for the nightly
build -->
<property name="nant.onfailure" value="build_failed" />
And the failure target:
<!-- Failure target to send a mail that the build failed -->
<target name="build_failed" >
<mail if="${SendMailResults}"
from="[EMAIL PROTECTED]"
tolist="[EMAIL PROTECTED]"
mailhost="mail"
message="You ... have ... f a i l e d.
The nightly build has failed. Sorry. Thank you for playing.
For Details, please see below:
----------------------------------
"
subject="[Build]"
>
<files>
<includes name="nightly.txt" />
</files>
</mail>
</target>
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=ick
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users
________________________________________________________________________________________________
This electronic mail (including any attachments) may contain information that is
privileged, confidential, and/or otherwise protected from disclosure to anyone other
than its intended recipient(s). Any dissemination or use of this electronic email or
its contents (including any attachments) by persons other than the intended
recipient(s) is strictly prohibited. If you have received this message in error,
please notify us immediately by reply email so that we may correct our internal
records. Please then delete the original message (including any attachments) in its
entirety. Thank you.