Add modificationHistroy to release?

I wish we could use JIRA for generating release file in build result. cc.net does have a ModificationHistory publisher, but for some reason, the version CCConfig I have doesn’t work for this. (Somebody filed the bug already, I did a vote.)

The workaround I’m using:

  1. Enable ModificationWriterTask in cc.net project publisher, this will generate a file named modifications.xml in artifact folder, which only contains the changes since last build.
  2. Create a NAnt task to merge modifications info into a modificationHistory.xml file. (idea from here)
  3. Create another NAnt task to transform the xml into a text file.
	<target name="publish.mod.history" depends="merge.mod.history" >
		<style style="${build.dir}\modifications.xsl"
			in="${CCNetArtifactDirectory}\modificationHistory.xml"
			out="${CCNetArtifactDirectory}\${application.version}\modifications.txt">
	    <parameters>
	        <parameter name="reportType" namespaceuri="" value="Plain" />
	    </parameters>
		</style>
	</target>

	<target name="merge.mod.history" description="add the new mod list to an existing xml file">
		<property name="xmlnodes" value=""/>
		<xmlpeek xpath="//ArrayOfModification" file="${CCNetArtifactDirectory}\modificationHistory.xml" property="xmlnodes"></xmlpeek>
		<property name="newnode" value="" />
		<xmlpeek xpath="//ArrayOfModification" file="${CCNetArtifactDirectory}\modifications.xml" property="newnode"></xmlpeek>
		<property name="xmlnodes" value="${newnode}${xmlnodes}" />
		<xmlpoke file="${CCNetArtifactDirectory}\modificationHistory.xml" xpath="//ArrayOfModification" value="${xmlnodes}" />
	</target>

Modifications.xsl:

<?xml version="1.0"?><!-- DWXMLSource="modificationHistory0.xml" -->
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"

     version="1.0">

    <xsl:output method="text"/>

    <xsl:variable name="modification.list" select="ArrayOfModification/Modification"/>

    <xsl:template match="/">
Modifications since last build (<xsl:value-of select="count($modification.list)"/>)
    <xsl:apply-templates select="$modification.list">
        <xsl:sort select="date" order="descending" data-type="text" />
    </xsl:apply-templates>
    </xsl:template>

    <!-- Modifications template -->
    <xsl:template match="Modification">
 (Revision:<xsl:value-of select="ChangeNumber"/>) <xsl:value-of select="FolderName"/>/<xsl:value-of select="FileName"/>, <xsl:value-of select="UserName"/> on <xsl:value-of select='substring(ModifiedTime, 0, 11)'/>, <xsl:value-of select="Comment"/>
    </xsl:template>

</xsl:stylesheet>

Result:

Modifications since last build (14)

(Revision:15) /trunk/build/modificationHistory0.xml, FMao on 2009-10-15,
(Revision:15) /trunk/build/modifications.xsl, FMao on 2009-10-15,
(Revision:12) /trunk/build/default.build, FMao on 2009-10-15, added new task to merge mod hist and transform xml
(Revision:12) /trunk/pbunit_demo.pbw, FMao on 2009-10-15, added new task to merge mod hist and transform xml

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s