|
CruiseControl.NET : NAnt Task
This page last changed on May 10, 2005 by gtackley@thoughtworks.com.
ExamplesMinimalist Example:<nant />
Full example: <nant> <executable>c:\fromcvs\myrepo\myproject\tools\nant\nant.exe</executable> <baseDirectory>c:\fromcvs\myrepo\myproject</baseDirectory> <buildArgs>-D:cvs.executable=c:\putty\cvswithplinkrsh.bat</buildArgs> <nologo>false</nologo> <buildFile>cruise.build</buildFile> <logger>My.Other.XmlLogger</logger> <targetList> <target>run</target> </targetList> <buildTimeoutSeconds>1200</buildTimeoutSeconds> </nant> Configuration Elements:
NAnt output in XmlCruiseControl.NET expects NAnt to generate its output as Xml so that the build results can be parsed and rendered appropriately. To accomplish this, CruiseControl.NET will, by default, launch NAnt using the "-logger:NAnt.Core.XmlLogger" argument. If you want to override this behaviour, specify the logger property in the NAntBuilder configuration in the ccnet.config file. If this element is specified but is empty then NAnt will be started with the default logger (though this may cause some problems for CCNet). It is also possible to instruct NAnt to log its output to an Xml file and then merge the file into the build using the File Merge Task. Source Control and NAntWhile CruiseControl.NET will detect modifications for you it will not check out changes. It is up to you to add targets to your nant script to do that for you. So, first you need to create a 'bootstrap' build file that is used to get the latest changes to your source tree whenever an update is comitted. A good place to put this build file is in the same directory as your project's normal buildfile. This bootstrap file should do 2 things:
The following is an example for a project under CVS control (it assumes that a propery called 'cvs.executable' is passed in from CruiseControl.NET - you can do this in the build/buildArgs section of the ccnet.config file): <project name="ccnetlaunch" default="go"> <target name="go" depends="update,build"/> <target name="update"> <ifnot propertyexists="cvs.executable"> <fail message="cvs.executable property not set, so can't update" /> </ifnot> <echo message="CVS Executable at [${cvs.executable}]" /> <exec basedir="." program="${cvs.executable}" commandline="-q update -P -d" /> </target> <target name="build"> <nant buildfile="myproject.build" target="ContinuousIntegration" inheritall="true" /> </target> </project> NOTE: The bootstrap buildfile above only updates the buildserver's local copy of your project's source. Before you even run CruiseControl.NET for the first time you need to checkout your project to the location on your machine where CruiseControl.NET will build it. NUnit and NAntCruiseControl.NET uses xsl to process the build log and produce html for display on the web page. Since xml is so easy to parse the nunit2 task in NAnt can produce xml output. The tasks must be configured to do that in order for test results to show up on the web page. Typically this is done by adding a formatter element to the nunit2 task and setting the type to be "Xml". Additionally the usefile flag of the formatter element must be set to "false". If it isn't the nunit2 task will try and save the output to a file and not write it out to the build log.<target name="test.unit" depends="compile" description="runs unit tests"> <nunit2> <formatter type="Xml" usefile="false"/> <test assemblyname="${build.dir}\${core.dll}" fork="true"/> <test assemblyname="${build.dir}\${console.exe}" fork="true"/> </nunit2> </target> It would be pretty tedious for developers to read the xml output when they run the build locally. Define a property for the build output type and set it to "Plain" and use the property in the formatter element.. <property name="outputType" value="Plain"/> ... <formatter type="${outputType}" usefile="false"/> ... Then in the ccnet.config file pass in a different value for outputType. <nant> ... <buildArgs>"-DoutputType=Xml"</buildArgs> ... </nant> Accessing CruiseControl.NET build labels in NAntCCNet will pass the current build label to NAnt via the NAnt property "ccnet.label". This means that you can access use this property to, for example, archive the newly built assemblies in a folder with the same name as the build label (this is what we do on CCNetLive . Here's some example NAnt script demonstrating how to do this:<target name="dist.publish" depends="dist"> <ifnot propertyexists="ccnet.label"> <fail message="ccnet.label property not set, so can't create labelled distribution files" /> </ifnot> <property name="publish.dir" value="D:\download-area\CCNet-Builds\${ccnet.label}" /> <mkdir dir="${publish.dir}" /> <copy todir="${publish.dir}"> <fileset basedir="dist"> <includes name="*"/> </fileset> </copy> </target> CCNet also passes a series of other properties to NAnt:
|
| Document generated by Confluence on Jun 26, 2005 17:22 |