Wednesday, April 22, 2009

Integrating Subversion with Axosoft OnTime

I've been meaning to sit down and get our ticket / bug tracker (Axosoft OnTime) integrated with our SCM tool (Subversion) for a while now. Today I finally ran out of excuses to keep putting it off. Having had a pleasant prior experience integrating Trac with Subversion, I wasn't expecting it to take too long. The real problem is the lack of information on the Internet about this subject. So, without further delay, here are the steps I went through to get our installation of OnTime and Subversion talking with each other.

Configure Source Control Management

The first thing you'll want to do is configure Source Control Management in OnTime. Right click on any of your projects (although I would suggest you do this from the root project) and select Manage Source Control. OnTime will then present you with the following screen:


  1. Set Subversion as your source control plug-in.
  2. Command Line Client -- TortoiseSVN will not cut it. If you don't have a command line client installed (VisualSVN is fine), any of the ones here will work. I have VisualSVN but I verified that the CollabNet one works as well. Enter the path to svn.exe.
  3. Server URL -- This is the same value you use for your source repository. It's usually something like svn://host/repositoryName.
  4. Username -- Your username in Subversion.
  5. Password -- Your password for Subversion
  6. Working Copy Location -- Location of the repository on your hard drive.
  7. Timeout Value -- This one is important. It defaults to 15 seconds. If you have a slow Internet connection or you're working with a large repository you will likely need more time. If you get a null reference exception that isn't handled, increasing this value may resolve your problem.
Configure Subversion Properties

Go to the subversion properties on the root folder in your repository and enter the following values:


bugtraq:number false is actually important for the way I'm getting around a specific design choice with OnTime. All of the primary keys for tasks, defects, incidents, features seem to be shared across ticket types. In order to properly navigate to the ticket, we're going to adopt a naming convention to tell TortoiseLinker.asp what type of issue we're dealing with so it will know where to send us.

When you enter the bug id on a code checkin, prefix the issue with a d for defect, t for task, and an f for feature.


Create TortoiseLinker.asp


Now that we've got our subversion variables setup, the only thing left is placing a script in your OnTime web app that will direct the user to the appropriate ticket.

  1. Create a file called TortoiseLinker.asp and put it in the root directory of your OnTime web application.
My file has the following contents, it's quite possible you will need to modify this for your needs, but this should give you the general idea of what's going on here.
<%
Dim urlid
Dim ticketType


'Set both of these values = to the bug id coming across
ticketType = request("id")
urlid = request("id")

'Grab the first character. (d = defect, t = task, f = feature)
ticketType = left(ticketType, 1)

Dim ticketTypeAsciiNumber

'Get the ascii value of the first character
ticketTypeAsciiNumber = Asc(UCase(ticketType))

'See if the ascii value of the first character equals d, f, or t
if(ticketTypeAsciiNumber = 68 or ticketTypeAsciiNumber = 70 or ticketTypeAsciiNumber = 84) Then
'Set the url to the actual bug number, ripping off the first character that indicates the issue type
urlid = right(request("id"), len(request("id"))- 1)

'defect
if(ticketTypeAsciiNumber = 68) then
response.redirect("/OnTime2008Web/Defects/ViewDefect.aspx?DefectId=" + urlid)
'feature
elseif(ticketTypeAsciiNumber = 70) then
response.redirect("/OnTime2008Web/Features/ViewFeature.aspx?FeatureId=" + urlid)
'task
elseif(ticketTypeAsciiNumber = 84) then
response.redirect("/OnTime2008Web/Tasks/ViewTask.aspx?TaskId=" + urlid)
'should never really get here
else
response.redirect("/OnTime2008Web/Defects/ViewDefect.aspx?DefectId=" + urlid)
end if
'the first number is something we don't support, just send them on to the defect page and hope for the best.
else
response.redirect("/OnTime2008Web/Defects/ViewDefect.aspx?DefectId=" + urlid)
end if

response.end
%>

Done! Now you can manually link files in OnTime to issues and you'll get links in the log messages from subversion that will take you directly to the issue in the web app.

One final note: I had to enable asp page processing on our server to get this to work. Directions on how to do that can be found here.

3 comments:

  1. Brandon, thanks for the post. If I read you correctly, you are not actually logging the changes that were made for a given defect (or feature, or task) to OnTime, but, still relying on a user to make the linkage manually. Correct?

    ReplyDelete
  2. @Scott --

    That is correct. All this will do is put a link in the subversion log you can use to pull up the defect, feature, task in the web app.

    I was really surprised how difficult it was to actually link the files automatically in OnTime at checkin. I did a lot of research on it (because that is really where all the value is) and it involves invoking stored procedures directly in the OnTime database. That's a boundary I was not comfortable in crossing.

    Hopefully OnTime will make it easier to implement that functionality in future versions.

    ReplyDelete
  3. Brandon, thanks so much for the post it works perfectly! It took me a little while to figure out that when I added the new properties to an existing repo I had to check the 'Apply property recursively' box in Tortoise, to get the properties to apply to all exsiting files & folders. With that done it worked like a dream. I have also found that everythings comes out in the wash in the Subclipse Eclipse plug-in aswell:

    http://www.meinbinary.com/2009/10/setting-up-axosoft-ontime-with-sql.html

    cheers

    Andy

    ReplyDelete