views:

320

answers:

1

In the interests of trying to speed up my NAnt/CruiseControl.Net/Ivy continuous build process, I was hoping to get NAnt to check if my codebase has changed on my local PC after performing a NAnt-based update, and then if the code has changed, then kick off the process to re-build that project and possibly raise a flag to build all subsequent components, irrespective of their change status.

Reason being, my build process is currently taking well over 12 minutes to complete a lot of work, and I'm thinking that I can get this time down by not building code that isn't going to change, as well as keep the devs in the office happier also.

We have investigated removing some of the projects from the build order, but they are all required in case of any change further up the build tree order.

+3  A: 

Couple of options I can see

1 - issue an svn status --show-updates before the svn up and work out if there are any changes ( should be as simple as counting the lines in the response - I think and up to date folder would generate only 1 line )

2 - change from svn-update task to exec task and redirect the output from svn up into a test file that you can post process to determine if any updates were made ( similar to first option ).

3 - Grab the svn log after the svn up with a task based on http://jonathanmalek.com/wp/?p=244 and then process the xml to determine if any changes were made. This would only work if you were guaranteed only 1 rev number increase as it only gets log info for last revision. Variation on this would be grab the log before the svn up and after and then compare them.

Personally I would go with option 2. Running svn up on an up to date working directory results in one line (At revision ) therefore change from using the svn update task to the following:

<target name="Svn-update">
  <!-- Default to true so failure mode is to build / signal build is required -->
  <property name="source.changed" value="true"/> 
    <exec 
          program="svn.exe" 
         commandline=’up′ 
          output="_update.log" 
          failonerror="true"/> 
    <property name="updates.count" value="0"/>
    <foreach item="Line" in="_update.log" property="updates.line" trim="Both">
        <property name="updates.count" value="${int::parse(updates.count) + 1}"/>
    </foreach>
    <if test="${updates.count==1}">
        <!-- An up to date working directory generates a single line "At revision xxx" -->
        <property name="source.changed" value="false"/>
    </if>
</target>

now you can use if="${source.change=='true'}" and unless="${source.changed=='true'}" to determine when you should and should execute the remainder of your build and notifications

Neal
Good effort so far, but I thinking that I need something more concrete to award the points. C'mon - give me some code!! :o)
Brett Rigby
You are the man! Good effort! 150 points coming your way!
Brett Rigby