ccnet and svn revision

August 6, 2007

UPDATE: This is old, obsolete and incomplete stuff that I’ve “ported” from my old blog for (in)completeness. If you’re still interested in this please send me an email or leave a comment.

In the previous post about CruiseControl.NET I’ve showed how to make the list of modifications into links to the trac diff page for each file. If you looked carefuly at the screenshot you could also see that the SVN revision number appears and is a link. How did that get there and where does it lead? No better place than the Trac page for the latest changeset so you can view all the changes at once.

To do it you need to modify an the header.xsl file in the ccnet dashboard. You can find it in the webdashboard\xsl subdirectory where you installed CruiseControl.NET. Open it and insert the following:

<tr>
  <td class="header-label" valign="top"><nobr>SVN Revision:</nobr></td>
  <td class="header-data">
    <a href="http://192.168.0.250/trac/{/cruisecontrol/@project}/changeset/{changeNumber}"><xsl:value-of select="changeNumber" />
    </a>
  </td>
</tr>

right after the last <tr> element in the file. You should get something like this:

<!-- Last Modification template -->
<xsl:template match="/cruisecontrol/modifications/modification">
  <xsl:if test="position() = 1">
    <tr>
      <td class="header-label"><nobr>Last changed:</nobr></td>
      <td class="header-data"><xsl:value-of select="date"/></td>
    </tr>
    <tr>
      <td class="header-label" valign="top"><nobr>Last log entry:</nobr></td>
      <td class="header-data"><pre><xsl:value-of select="comment"/></pre></td>
    </tr>
    <tr>
      <td class="header-label" valign="top"><nobr>SVN Revision:</nobr></td>
      <td class="header-data"><a href="http://192.168.0.250/trac/{/cruisecontrol/@project}/changeset/{changeNumber}"><xsl:value-of select="changeNumber" /></a></td>
    </tr>
  </xsl:if>
</xsl:template>

Not only can you now see the svn revision number for the last build but you can also go the the diff page in its Trac repo. Yay!

Note: This will only work if the project has the same name in both CruiseControl.NET and Trac.

Tags: ,

Leave a Reply