# Wednesday, August 22, 2007
« MSBuild Series Part 1 - The Basics, Proj... | Main | ItemGroups Affect Build Script Load Time... »

I have multiple projects checked into my Subversion repository, but CC.NET out of the box will build all of them when any source file get checked into any part of the repository under trunk.  The desired behavior is to have only a build get kicked off when a source file gets checked in under its project folder.  I was able to do this when using Perforce with CC.NET by creating multiple views, but in SVN I haven't found a way to do this yet.

Unfortunately there doesn't seem to be a built in way to specify a URL filter in CruiseControl.NET for when a build gets kicked off in Subversion (I'm using CC.NET 1.3).  The current SVN source control provider in CC.NET only takes a trunk URL, and doesn't like it when you specify a subdirectory.    For now I've just hacked the Svn class in CC.NET to apply a filter using a new TrunkWatchUrl element.  In the following example, a build will only be kicked off when a change happens under http://svnserver/svn/gp/trunk/MyProject.

<sourcecontrol type='svn'>

  <trunkUrl>http://svnserver/svn/gp/trunk</trunkUrl>

  <trunkWatchUrl>http://svnserver/svn/gp/trunk/MyProject</trunkWatchUrl>

  <tagBaseUrl>http://svnserver/svn/gp/tags</tagBaseUrl>

  <workingDirectory>c:\autobuild\src\server</workingDirectory>

  <executable>C:\Program Files\Subversion\bin\svn.exe</executable>

  <username>domain\svcautobuild</username>

  <password>pass</password>

  <autoGetSource>true</autoGetSource>

  <tagOnSuccess>true</tagOnSuccess>

</sourcecontrol>

 

The associated code changes to Svn.cs:

[ReflectorProperty("trunkWatchUrl", Required = false)]

public string TrunkWatchUrl;

 

public override Modification[] GetModifications(IIntegrationResult from, IIntegrationResult to)

{

    ProcessResult result = Execute(NewHistoryProcessInfo(from, to));

    Modification[] modifications = ParseModifications(result, from.StartTime, to.StartTime);

 

    if (!string.IsNullOrEmpty(TrunkWatchUrl))

    {

        string trunkPath = TrunkWatchUrl.ToLower();

        modifications = Array.FindAll(modifications, delegate(Modification mod)

        {

            string[] folderParts = mod.FolderName.Split('/');

            if (folderParts.Length < 2)

                return false;

 

            string modFirstPathPart = folderParts[1];

            int trunkStartIdx = trunkPath.IndexOf(modFirstPathPart);

 

            if (trunkStartIdx < 0)

                return false;

 

            string localTrunkPathPart = trunkPath.Substring(trunkStartIdx).ToLower();

            return mod.FolderName.ToLower().Contains(localTrunkPathPart);

        });

    }

 

    if (UrlBuilder != null)

    {

        UrlBuilder.SetupModification(modifications);

    }

 

    return modifications;

}

 

Wednesday, August 22, 2007 10:59:51 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [4]  | 
Saturday, August 25, 2007 9:09:44 AM (GMT Standard Time, UTC+00:00)
Hi Shawn,

I have been using Cruise Control with svn project directories for quite a while and never run into the issue you mention. For our trunk url, we point it to the url of the trunk branch of our project, like server/trunk/SomeProduct.

The only difference between what we have running right now and what you have in your example is that we use file urls, as our build server is also our cruise control server. So we have paths like file:///E:/svn/trunk/CashFlow.

Not sure if that helps, but let me know if you'd like to see the whole config file or anything like that. Cheers!
Saturday, August 25, 2007 9:09:58 AM (GMT Standard Time, UTC+00:00)
Hi Shawn,

I have been using Cruise Control with svn project directories for quite a while and never run into the issue you mention. For our trunk url, we point it to the url of the trunk branch of our project, like server/trunk/SomeProduct.

The only difference between what we have running right now and what you have in your example is that we use file urls, as our build server is also our cruise control server. So we have paths like file:///E:/svn/trunk/CashFlow.

Not sure if that helps, but let me know if you'd like to see the whole config file or anything like that. Cheers!
Saturday, August 25, 2007 9:10:33 AM (GMT Standard Time, UTC+00:00)
Sorry for the double comment! It said it didn't work the first time.
Thursday, August 30, 2007 4:37:32 PM (GMT Standard Time, UTC+00:00)
Hey Chris, thanks for the tip. I went back to our CC.NET server and changed trunkUrl to point to a subdirectory of trunk and just as you said - it worked. I'm not sure why it now works and didn't before. I've made some changes to our builds since then so perhaps somewhere along the way I stopped doing something stupid.
Sneal
Comments are closed.