Platinum Solutions Corporate Website


Subversion and Bugzilla integration with BugTraq and ScmBug

O.K. I have Subversion and Bugzilla sharing accounts (see here) and I have WebSVN allowing only authorized users to browse the repository (see here).  Now I would like to be able to link a Subversion commit to a Bugzilla bug.

Ideally, when I do a commit, I would like my GUI tool to include a "Bug ID" text field to enter in bug numbers. I’d like the bug numbers to be added to the commit log message in a standard way, and I’d like the specified bug to be updated in Bugzilla to indicate the modified files.

I was able to accomplish all these things with the BugTraq properties (and tools that support BugTraq like TortoiseSVN and Subclipse) and the ScmBug integration service.

BugTraq

Before I start talking about BugTraq properties, here is a quick introduction to Subversion properties in general. Subversion properties are "metadata" that you can attach to versioned files and directories. This metadata (name-value pairs) is primarily intended to be used as processing directives by client applications. Subversion itself defines some properties, such as the "svn:eol-style", which is used to specify that you want a file to be converted to a specific "end of line style" (like CRLF) when a new version is committed.

BugTraq are a set of properties for a standardized way of integrating Subversion clients and third party bug tracking software. The original spec can be found at:
http://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/doc/issuetrackers.txt
(You’ll be prompted for user id and password, use "guest" with no password)

The main property is "bugtraq:message". This property serves two purposes:

  1. The fact that this property is set should trigger the client to prompt for a bug id when committing.
  2. The bug id is added to the commit log message using the format specified.

I have "bugtraq:message" set to something like "Issue: %BUGID%", where the %BUGID% field is how you specify where the bug id is to be inserted. Both TortoiseSVN and Subclipse honor the "bugtraq:message" property so, when you do a commit in one of these tools, a new text field for the Bug ID just "magically" shows up in the GUI. If you enter in a value, your commit log message has "Issue: bug_id" appended to it.

The other property that I’m using is "bugtraq:url" where you specify a format to create a URL. This is used by a client to create a hyperlink back to the bug tracking system.

I have the "bugtraq:url" property set to
"http://my.server.com/bugzilla/show_bug.cgi?id=%BUGID%".
WebSVN honors this BugTraq property so, when I view a commit message that has the "Issue: bug_id" appended to it, WebSVN displays the bug id value as a hyperlink back to Bugzilla.

So, with BugTraq, I now have a way of specifying a Bug ID when I commit and that bug id is placed in the commit message in a standard way. But Bugzilla still doesn’t know anything about it. That’s where ScmBug comes in.

ScmBug

The ScmBug project (http://www.mkgnu.net/?q=scmbug) aims to create a generic bridge between Software Content Management (SCM) systems and Bug tracking systems. It currently supports CVS and Subversion on the SCM side, and Bugzilla and Mantis on the Bug tracker side.

There are two parts to ScmBug:

  1. Event hook scripts that integrate into the SCM (referred to as "glue").
  2. A server process that integrates with the bug tracking system.

ScmBug uses a Subversion "pre-commit" hook to parses the commit log message looking for any Bug IDs. In order for this to work, the commit log message has to be formatted in standard way (and thanks to BugTraq, it is!) When it finds a Bug ID, it connects to the server process and passes the Bug ID and commit information.

The server process then updates Bugzilla with the given information. It does this by calling some of the perl scripts in the Bugzilla installation directory.  This means that the server process has to be on the same machine as Bugzilla.

I’m running Bugzilla on Fedora Core 5, so I used the ScmBug RPMs to install. They put a "scmbug-server" start script in "/etc/init.d".
You have to tweak the "daemon.conf" file in "/etc/scmbug" to tell it where to find Bugzilla before starting the server.

Next, you have to install the "Glue" (the Subversion hooks). ScmBug comes with a command line tool called "scmbug_install_glue" to help with this (see the ScmBug documentation on how to run it).

After this, you have to tweak the "glue.conf" file which will be located in the "hooks/etc/scmbug" directory in your Subversion repository.

The primary things you need to change in the "glue.conf" file are the regular expressions used to parse Bug IDs. Since my "bugtraq:message" = "Issue: %BUGID%", I found that the following settings work:


bugid_regex => ‘.*Issue:\s*(.*?)$’,
bugid_split_regex => ‘,\s+#|\s+#|,|\s+’,
log_regex => ‘^(([^\r\n]|[\r\n])*)Issue:.*$’

I also changed the "presence_of_bug_ids" property to "optional", otherwise you wouldn’t be able to do a commit without a bug id. I also disable the "minimum_log_message_size" enforcement.

Gotchas!

I ran into a few problems along the way while trying to make this work. Here are some things to keep in mind...

  • The BugTraq properties are set on a directory, and clients will apply the BugTraq property to any child directories. So if you set the BugTraq property on the directory that is at the root of the repository, then any commit to a sub directory (trunk, branches, tags, etc) will have the Bug ID text box.
  • The directory you check out must have BugTraq properties set! It is uncommon to check out an entire repository. Usually you only check out the trunk or a particular branch. In this case, the BugTraq properties must be set on the directory you checked out. The client will not propagate the BugTraq properties from the parent directory because, since you didn’t check it out, the client doesn’t know anything about it. What I did was set the properties at the root of the repository using TortoiseSVN and used the "recursive" check box to have the properties also set on the trunk and branches.
  • I had problems with SELinux and ScmBug. Access to my Subversion is through Apache so, when you do a commit, svn is called from the httpd process. This commit process subsequently tries to make a network connection to the ScmBug server process which kept failing for me. I never fully figured out why, but I made a guess that it had to do with Fedora and SELinux. I ended up disabling SELinux, and everything worked fine after that.
  • I had problems with ScmBug and the combination of Subclipse and Subversion 1.2. If I entered a multi line comment, ScmBug would return an error. This actually turned out to be due to the "svnlook" command and its inability to handle comments with a mix of end-of-line styles. The svnlook problem is fixed in Subversion 1.3
  • Don’t forget to tweak the "glue.conf" file! Modify those regular expressions, and you probably want to "relax" some of the enforcement rules that ScmBug provides.
  • The smbug-server process is not secure (anyone can connect to it). I run Subversion and Bugzilla on the same machine and use a firewall to at least make sure that only local processes can access it. (This issue is on the ScmBug developers "TODO" list).

Comments

Debasis (not verified) Wed, 1969-12-31 19:00

Hi I tried all the steps for integrating scmbug,subversion and bugzilla
1.i am using SCMBUG_RELEASE_0-26-15 for wondows
2.bugzilla 3.4.1
3.VisualSVN Server 2.0.8

Bugzilla is installed in one system and VisualSVN Server is installed in my system.

so i started the integration daemon.
Then i m running scmbug_install_glue.pl .its given below

C:\Program Files\Scmbug\bin>scmbug_install_glue.pl --scm=Subversion --p
C --repository=C:\Repositories --bug=1 --binary-paths=C:\VisualSVNServe
aemon=192.168.105.3

I am encountering with the following error

Scmbug error 32: Unable to connect to integration daemon at '192.168
port '3872'. Is the daemon running ?

I am having few doubt
1.if bugzilla is running on one system and VisualSVNServer in another system is it mandatory to install scmbug in both the system??
2.How can i come to know the integration daemon is started.
I am runnign like this-C:\Program Files\Scmbug\etc\init.d>scmbug-server.bat
i am getting the message like below
Starting SCM to bug-tracking integration daemon: scmbug_daemon

C:\Program Files\Scmbug\etc\init.d>
is this enough to understand that daemon is started??

3.How can i stop the scm-bug server

Anonymous (not verified) Wed, 1969-12-31 19:00

hi,

Please help me in solving this:

*******************************************
2009/05/11 16:54:22 Scmbug WARN> Daemon.pm:81:Scmbug::Daemon::Daemon::read_configuration - Read configuration file 'C:/Program Files/Scmbug/etc/scmbug/daemon.conf'
2009/05/11 16:54:22 Scmbug ERROR> Daemon.pm:114:Scmbug::Daemon::Daemon::read_configuration -
*******************************************
**
**
** Scmbug error 79: Package 'Bugzilla' not found in installation directory 'C:\Program Files\Apache Group\Apache2\htdocs\Bugzilla'.
Initialization of bug-tracking system 'Bugzilla' version '3.0.6' failed. This could be due to an unsupported version of this system, or misconfiguration.
**
**
*******************************************

please help

Rafael Sanches (not verified) Wed, 1969-12-31 19:00

Hey! I love the SVN integration with bugzilla.

I also made a perl script that make it possible to merge from a branch ("trunk" for example) to another branch ("stable" for example), that has a specific bug id. That have the same effect as creating a separate branch just for that bug id, and it is very useful for mini projects that you did not expected lots of commits, but they just happen :)

http://mufumbo.wordpress.com/2008/05/10/simple-script-to-merge-commits-from-a-bugzilla-id/

does someone know something similar or standard to do the same thing?

Morgoth (not verified) Wed, 1969-12-31 19:00

Can't start scmbug-server on Mandriva 2008 because of perl not supporting multithread. A bug is already open:
http://qa.mandriva.com/show_bug.cgi?id=34941

# /etc/init.d/scmbug-server start
Starting SCM to bug-tracking integration daemon: scmbug_daemon/usr/share/scmbug/ lib/Scmbug/Daemon/Process.pm line 24:

This Perl hasn't been configured and built properly for the threads
module to work. (The 'useithreads' configuration option hasn't been used.)

Having threads support requires all of Perl and all of the XS modules in
the Perl installation to be rebuilt, it is not just a question of adding
the threads module. (In other words, threaded and non-threaded Perls
are binary incompatible.)

nal (not verified) Wed, 1969-12-31 19:00

Hi,

I am able to commit a file with a bug id but do not see the updates in the Bugzilla.
There are error msgs in the scmbug logs & the activity logs displays
Fri Nov 30 15:28:36 2007 127.0.0.1:3348 Connection from processed
Fri Nov 30 15:28:56 2007 127.0.0.1:3350 Processing connection from
Fri Nov 30 15:28:56 2007 127.0.0.1:3350 Processing an 'activity_verify' for bug id '3' from SCM user 'username'
Fri Nov 30 15:28:57 2007 127.0.0.1:3350 Connection from processed

I am using

Bigzilla version -> 3.0.2
SCMBug version -> 0.23
Subversion version -> 1.4.5
OS -> Win XP Professional

Thanks.

Gordon (not verified) Wed, 1969-12-31 19:00

Hi!

  Everything aparently went well installing everything and the bug ids are entered into Subversion as expected.  In the activity log, scmbug says it is processing the events. No errors in the error log. But bugzilla is not bieng updated.

  I am new to bugzilla and am not sure where to look for any errors it might be throwing, but nothing is obvious anywhere.

Bigzilla version -> 2.22.1

SCMBug version -> 0.18.3

Subversion version -> 1.2.1

All running on Win XP Pro

Any help would be appriciated.

Thanks!

Gordon

 

Moran (not verified) Wed, 1969-12-31 19:00

Hello

when i commit a file to SVN with bug-id everything seems fine but i cant see any change in the bugzilla

in activity.log i get:

the changeset command could not be added. this must be to a bug in the bug-tracker backend.

what should i do ?

Moran (not verified) Wed, 1969-12-31 19:00

the activity log of the integration deamon shows an error:

"this due to a bug in the bug-tracker backemd"

:(

Steven (not verified) Wed, 1969-12-31 19:00

Nice article, thanks.

A nice feature that's still missing (I believe) is to change the resolution of a bug to fixed via a commit.

A tip for those installing from source: scmbug has a couple of dependencies, mostly related to generating the docs (docbook, latex2html, ...). The configure script catches most of them, but one it doesn't catch is the installation of docbook 4.2. I had 4.1 and 4.4 and I couldn't run 'make'. Took me a while to figure out that docbook 4.2 had to be installed.

 

Brian Smith (not verified) Wed, 1969-12-31 19:00

Which version of Bugzilla and SCMBug were used? I get DB errors when SCMBug tries to update Bugzilla. I'm using Bugzilla 2.22 and SCMBug 0.15.5

Chris (not verified) Wed, 1969-12-31 19:00

The scmbug website seems to be down at the moment. You wouldn't still happen to have a copy floating around that I might be able to obtain somehow?

I'm currently trying to integrate subversion and bugzilla. This is a good article, by the way.

David OShea (not verified) Wed, 1969-12-31 19:00

If you email the author at the email address shown at http://sourceware.org/ml/binutils/2004-01/msg00412.html he'll email you scmbug.  He did for me.  He will be bringing the site back up later this month.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options