CruiseControl.Net Update
So, I explained yesterday how I got CruiseControl.Net installed as part of my
quest to institute Continuous Integration in my development project. After I
published yesterday's entry, I found that I hadn't done one crucial thing.
Getting The Latest Version From Subversion Before The Build
My build kept happening every time I "committed" a new version of a source
file to Subversion, but my changes weren't showing up in the CruiseControl.Net
build. I soon realized my mistake, I needed to modify the the NAnt build files
with a couple of new <target>'s, one for getting the latest version from source
control, and one for calling the "update" target and then the "build" target. I
could have just added the "update" to the "build" target, but I may want to just
"build" the current snapshot rather than always getting the latest version. So
now I have the following for my main (D:\VirtualCellar\default.build) file. I
found this page helpful in
setting up CruiseControl.Net with Subversion.
<?xml version="1.0"?>
<project name="VirtualCellar" default="build" basedir=".">
<property name="debug" value="true"/>
<property name="build.deploy" value="release"/>
<property name="build.business" value="Lorengo.VirtualCellar.Business"/>
<property name="build.business.tests" value="Lorengo.VirtualCellar.Business.Tests"/>
<sysinfo/>
<target name="build" description="compiles projects">
<nant buildfile="${build.business}/default.build" target="build"/>
<nant buildfile="${build.business.tests}/default.build" target="build"/>
<copy todir="${build.deploy}/bin" file="${build.business}/bin/debug/${build.business}.dll"/>
</target>
<target name="update" description="Gets the latest version from source control">
<exec basedir="." program="d:\program files\subversion\bin\svn.exe" commandline="update" />
</target>
<target name="buildLatest" description="Builds the latest version from source control" depends="update,build" />
</project>
|
The "buildLatest" target depends the "build" target which depends on the
"update" target. This is backwards, according to the documentation according to
the
documentation it should be depends="build,update", but it works for me.
You'll notice that I've added an <exec> task to get the latest version from
source control. This gets the latest version for the basedir and all child
folders. I also updated my other default.build files for the other projects to
do this step should I wish to only build a project.
So, I check commit these to Subversion and it fixes my problem right? Wrong!
Because the existing default.build files in the d:\build\VirtualCellar folder
don't have the new <target>s so the update never happens, I need to manually
type the "svn update" command in the d:\build\VirtualCellar folder to bring down
the latest version. In addition I also need to update the d:\program files\CruiseControl.Net\Server\ccnet.config
file to build the new "buildLatest" target. Here's the updated
ccnet.config file.
<cruisecontrol>
<project name="VirtualCellar">
<webURL>http://localhost/ccnet</webURL>
<schedule type="schedule" sleepSeconds="300"/>
<sourcecontrol type="svn">
<executable>D:\program files\subversion\bin\svn.exe</executable>
<trunkUrl>file:///D:/Svn/VirtualCellar/trunk</trunkUrl>
</sourcecontrol>
<build type="nant">
<executable>D:\Program Files\nant-0.84\bin\nant.exe</executable>
<baseDirectory>D:\Build\VirtualCellar</baseDirectory>
<buildFile>default.build</buildFile>
<buildargs></buildargs>
<targetList>
<target>buildLatest</target>
</targetList>
<buildTimeoutSeconds>300</buildTimeoutSeconds>
</build>
<publishers>
<xmllogger>
<logDir>..\web\log</logDir>
</xmllogger>
</publishers>
</project>
</cruisecontrol> |
In addition to the change in the <target> node, you'll see that I've added a
<publishers> node that contains an entry for a log directory. This is where the
resulting build log will get created. I made a d:\program files\cruisecontrol.net\web\log
folder and pointed the logdir there.
Setting up the Web
I went and setup a Virtual Directory in IIS to point to the d:\program files\cruisecontrol.net\web
folder and named it CCNET, so now when I go to
http://localhost/ccnet, I get a screen like
this

You can see here that it took me a few tries to get the build to successfully
get the latest version from source control. This entry shows that the last build
was successful, and it's been an hour since it's done another build. Remember it
checks to see if there are any changes, and builds if there are any.
You may
also notice the "Test Details" and "FxCop" links. CruiseControl.Net will
automate these for you as well. That will be my next task for CC.Net.
ThoughtWorks gives a
nice overview picture on how CruiseControl.Net works.
Unit Tests for
First User Story Complete
I've completed my
first set of Test Cases for my first
User Story. All of them pass!

I've ended up with the following two classes (Cellar & Wine). I'm satisfied
with the current implementation for the first user story, but I can already see
problems with this implementation. I need to switch focus to the Wine class and
devote some modeling time to my project. In particular how Wine objects come
into being. I think there's a WineCatalog or somesuch class in my future that
will hold all of the known wines. So that's what I'll be working on today and
hopefully publish my intial model tomorrow!.
