A while ago, I posted a simple stop-gap solution for retrieving Subversion revision numbers during a CruiseControl.NET build, and had hoped that functionality would shortly make it into a release. Well, it hasn’t, and I have had to revisit this recently. Here’s a better solution than the original (using Subversion 1.2.0):
<echo message="Retrieving Subversion revision number"/>
<property name="svn.revision" value="00"/>
<exec
program="svn.exe"
commandline=’log "${project::get-base-directory()}" –xml –limit 1′
output="_revision.xml"
failonerror="false"/>
<xmlpeek
file="_revision.xml"
xpath="/log/logentry/@revision"
property="svn.revision"
failonerror="false"/>
<echo message="Using Subversion revision number: ${svn.revision}"/>
A little more generic, and much closer to the point–this one does a better job of getting the appropriate Subversion revision number.