Subversion (SVN) and Concurrent Versions System (CVS) are two popular open source configuration management tools for which Hackystat sensors are available. While SVN and CVS aren't specific to either Java or Ant-based software development, measuring configuration management events is very useful in this (and most other) development domains. This section describes the Subversion sensor; the CVS sensor is quite similar.
Installation of a Subversion system is beyond the scope of this section. Please consult the Subversion installation guide for details. This Ant task and sensor assume only that you have access to a Subversion server where your project files are located.
Example 4.34, “svn.build.xml” shows the svn.build.xml file, which defines the Ant target used to extract data from a Subversion server and send it to Hackystat.
Example 4.34. svn.build.xml
<project name="stackyhack.svn" default="svn.sensor">
<description>
Provides an Ant task to extract Commit data from a Subversion server, then send this data off to Hackystat.
Note: You typically invoke this with:
ant -Dsvn.workspaceroot=[workspace root] -Dsvn.userkey=[userkey] -Dsvn.smptserver=[smtpserver] -f svn.build.xml
</description>
<import file="build.xml"/>
<property name="svn.userkey" value="unknown"/>
<property name="svn.smtpserver" value="mail.hawaii.edu"/>
<property name="svn.workspaceroot" value="c:/svn-csdl"/>
<property name="svn.email" value="user@hackystat.org"/>
<target name="svn.sensor" description="Extracts Commit data from Subversion and sends it to the Hackystat server" >
<!-- Define the svn extractor taskdef, failing the build if the sensor is not installed. -->
<available classname="org.hackystat.sensor.svn.SvnSensorAntTask" property="svn.sensor.available"/>
<fail unless="svn.sensor.available" message="Error: Subversion sensor not installed."/>
<taskdef name="hacky-svn" classname="org.hackystat.sensor.svn.SvnSensorAntTask" />
<hacky-svn
repositoryName="csdl"
repositoryUrl="svn://hackydev.ics.hawaii.edu/csdl/StackyHack"
fileNamePrefix="c:/csdl-svn/StackyHack"
verbose="${hackystat.verbose.mode}"
fromDate="2006-03-14"
toDate="2006-03-15"
defaultHackystatAccountKey="${svn.userkey}"
fromEmail="${svn.email}"
toEmail="${svn.email}"
smtpServer="${svn.smtpserver}"
debug="false" />
</target>
</project>
The svn.build.xml defines the <svn.sensor> target that sends a request to a Subversion server to commit data for a given repositoryUrl between a given set of dates, and then send that data to a Hackystat server.
Before running the Subversion sensor, you must install it. General instructions on installing sensors are provided in Chapter 2, Client-side configuration: Tool sensor installation; instructions for specific sensors are provided in Chapter 26, Sensors. After installation, your hackyInstaller Subversion configuration window should look something like the screen image in Figure 4.22, “ HackyInstaller configuration screen for Subversion sensor ”.
Example 4.35, “svn.sensor invocation” shows the output from invoking the <svn.sensor> target. Note that the Subversion sensor normally consults the UserMaps file defined in HackyInstaller in order to determine which Hackystat account to send each retrieved Commit sensor data entry to. In this case, no UserMap file was defined, and instead the svn.default.userkey was supplied to indicate that all retrieved commit data should go to this account. In the listing below, the actual user key is replaced by "XXXXXXXXXXXX".
Example 4.35. svn.sensor invocation
C:\svn-csdl\StackyHack>ant -Dsvn.workspaceroot=c:\svn-csdl -Dsvn.userkey=XXXXXXXXXXX -f svn.build.xml Buildfile: svn.build.xml svn.sensor: svn.sensor: [hacky-svn] Processing commits between Mon Mar 13 23:59:59 CET 2006(exclusive) to Wed Mar 15 23:59:59 CET 2006(inclusive). [hacky-svn] SVN revision is from 279 to 284 [hacky-svn] Processing CommitRecordEntry (/StackyHack/lib[278] ==> null[279]) [hacky-svn] Processing CommitRecordEntry (/StackyHack/pmd.build.xml[265] ==> /StackyHack/pmd.build.xml[280]) [hacky-svn] Processing CommitRecordEntry (/StackyHack/doxygen.build.xml[265] ==> /StackyHack/doxygen.build.xml[280]) [hacky-svn] Processing CommitRecordEntry (/StackyHack/jira.build.xml[265] ==> /StackyHack/jira.build.xml[280]) [hacky-svn] Processing CommitRecordEntry (/StackyHack/findbugs.build.xml[276] ==> /StackyHack/findbugs.build.xml[280]) [hacky-svn] Processing CommitRecordEntry (/StackyHack/build.xml[265] ==> /StackyHack/build.xml[284]) [hacky-svn] Processing CommitRecordEntry (null[-1] ==> /StackyHack/svn.build.xml[284]) [hacky-svn] Processing CommitRecordEntry (/StackyHack/.classpath[51] ==> /StackyHack/.classpath[284]) [hacky-svn] Send from user 'XXXXXXXXXXXXX' to host http://hackystat.ics.hawaii.edu/ successful [hacky-svn] Hackystat data on 8 commit entries sent to http://hackystat.ics.hawaii.edu/ BUILD SUCCESSFUL Total time: 1 minute 1 second
Once you've invoked the sensor, you can verify that this data was received at the server by using the List Sensor Data command. Figure 4.23, “ List Sensor Data with Subversion Commit data ” illustrates what this page might look like after receiving the StackyHack data from the Subversion sensor.
![]() | Careful of the timestamp! |
|---|---|
Unlike other sensors, which will send data using a timestamp associated with the time at which the sensor is run, the SVN sensor sends data using timestamps associated with the time that the data was actually committed! Thus, regardless of when you run the above command, the data will always be sent with timestamps around March 13, 2006. | |