Svn Bugzilla Integration

First off, nothing here is new :). Just collated stuff from around the web, integrated svn+bugzilla on a virtual machine. This step by step guide is here ‘cos 15 days from now I wont remember how I managed to get it off the ground :).

What does it mean to integrate a SCM (software configuration management) tool with a bug tracker?

Here’s some of the things that we’d like to see happen

1. When you checkin files, checkin comments are mandatory. Furthermore, checkin comments should refer an open bug assigned to the user bug in the bug tracker . If any of this fails, check in should fail.

ErrorReport


2. When you checkin a file, the check in comments should further be checked for minimum length

3. The checkin comments should propagate to the bug tracking software and be recorded as comments against the bug.

4. In addition to the check in comments, the comment in the bug tracking software includes,

Name of the person checking in files

List of files that were checked in

SVNcheckinError

Setup

Okay, now to the meat:

Here’s the setup

As you can see, I’m running debian and Subversion 1.1.4
OS-unamea
Bugzilla version is 2.16.7

We’ll step through getting each of these up (other than debian linux itself)

In addition to the Subversion and Bugzilla, we need an additional piece of software that sits in between the two and does the magic – this is another open source project called Scmbug. In a nutshell, it hooks into Subversion using pre-commit and post-commit hooks and uses Bugzilla’s perl api’s to manipulate bugs stored in the bug db. I’m using scmbug 0.18-3 which is the version advised on the scmbug homepage on freshmeat.net.

A note on getting a machine to do all the setup – you dont need one :). Here’s how

1. Download the free vmware player from VMWare download .

2. Download Debian Sarge, minimal (netinstall) version.

3. Launch the vmx file. You’ll have linux vm booting inside windoze :).

This is the minimal install of debian – so if you need to install additional software (which you no doubt will), you can pick and choose. In addition, if you have the debian dvd/cd, you could probably coax it to use local resources for getting the .debs.

Sidenote – Using the Aptitude package manager

Debian’s package manager interface Aptitude makes it a breeze to get debian packages up and running. It takes care of dependencies and has a decent interface to it. What follows is a really short tutorial on aptitude.

You’ll need to be root or sudo root to run aptitude. On the bash prompt:

sudo aptitude

You’ll get aptitude’s main screen

aptitude101

It shows top level packages. You can navigate around with arrow keys and Enter expands a category.

We will use the more powerful search to locate packages and install them. Here are the keys

/ (forward slash) – search.

To go to the next match, press / again.

+ (plus) — select a package for installation. It will be highlighted in green. It will also select any dependencies.

– (minus) – deselect a package. If the package is installed, the package is marked for uninstallation.

g – go – go and do the changes. If dependencies were selected, and intermediate screen shows the packages to be installed/removed. Press g again to download the .debs and commence installation.

q – quit aptitude

F10 – access menu. Once the menu drops down, use the arrows.

Hopefully, that should see you through any installations required. We’ll go to the installations next.

Installing Subversion, Bugzilla and scmbug.

Subversion

Here’s the big picture below.

  1. Install Apache2 from aptitude.
  2. Check your installation of Apache by doing http://<ip&gt; – you should get a It works page :).
  3. Select subversion and install it.
  4. Select libapache2-svn package and install.
  5. Finally, install websvn.

The best place to start will be with subversion. A good tutorial on installing subversion on debian is here.

Also, since we will be accessing SVN using webdav, you can skip steps related to setting up ssh and password less ssh access from clients.

Now test subversion at the end. Install tortoiseSVN on your windows machine and verify that you can import a folder and then check in files.

Also verify websvn by accessing http://<ip>/websvn

Bugzilla

Okay, so bugzilla is a little bit more complicated. It isnt a well behaved citizen yet :).

  1. Install mysql via aptitude. Aptitude will run debconf and ask you to specify username, password etc.
  2. Now select and install Bugzilla. Choose the ‘automatic’ installation mode. It will ask you for bugzilla administrator user name. Be sure to enter a valid email id – ie, with an @ and the domain part containing atleast one period. I used root@localhost.localdomain – you can too.
  3. Verify that Bugzilla works. Point your browser to http://<ip>/cgi-bin/bugzilla/index.cgi. You should get bugzilla’s antsy page.
  4. If you get here, create a TestProduct – ideally the same name as the name you gave to your subversion repository.
  5. Create a Bugzilla user – you want this to be similar to the subversion username
    1. For ex: if the subversion user is iunknown, then create a bugzilla user iunknown@localhost.localdomain. Later on when we configure the glue between svn and bugzilla, we’ll define a mapping to convert from svn usernames to bugzilla users.
  6. Create a bug – this is the bug against which we’ll set up bugzilla/svn integration.

Scmbug

Scmbug is the naughtiest of them all and takes the longest to get off the ground. Also, scmbug should be installed locally on the machine that hosts bugzilla

  1. Download .debs from scmbug homepage
  2. since these are .debs directly, we’ll use dpkg to install. Its typically
    • dpkg –install <.deb filename>
    • The order to install is
      • scmbug-common
      • scmbug-server
      • scmbug-tools
      • scmbug-docs
  3. Note that just installing the packages does not configure them to run right. Most probably, the scmbug-server daemon startup would have failed during startup.

We’ll go about setting that right next.

  1. Open /etc/scmbug/daemon.conf in an editor as root.
  2. Entries to edit are:
    • version
    • installation_directory
    • database_name
    • database_username
    • database_password
  3. The next part is mapping subversion usernames to bugzilla usernames. This can be done in the mapping section. Search for mapping_regexes

‘(\w+)$’ => ‘$1@localhost.localdomain’
maps a username like raghu to raghu@localhost.localdomain

That’s about all the configuration that you need. Try starting the scmbug_server

/etc/init.d/scmbug_server start

Some ickiness that I faced:

Scmbug server fails to start with a warning for uninitialized variable in Daemon.pm

In my case, this error came up while checking if the LDAP should be used for mapping. Locate daemon.pm ususally in /usr/share/scmbug/libusr/share/scmbug/lib/Scmbug/Daemon/Daemon.pm
and comment out the code for LDAP integration.

2. Unable to see changes to globals.pl

/etc/init.d/scmbug_server stop

doesnt really kill the server. Use a kill -9 to kill the scmbug server and restart.

Glue installation

The final piece in the jigsaw to be configured – the subversion hooks so that subversion queries against the scmbug_server. Run

scmbug_install_glue –scm=Subversion –product=TestProduct \
–repository=/tmp/testrepository –bug=770 –binary-paths=/bin,/usr/bin \
–daemon=127.0.0.1

This assumes that bugzilla product name is TestProduct and the scmbug server is running locally on the loopback address. Furthermore , Subversion repo is located at /tmp/testrepository. if you do want to change anything, you can edit the Glue.conf file at <repopath>/hooks/etc/scmbug/glue.conf.

If the hook installation goes through fine, you can go ahead and give it a spin. Log a bug and then commit some files against it. Your comment should be of the form bug 1: [ie following the bug pattern defined in the glue.conf]

Further customization

You can customize glue.conf to enable/disable policies on a repository level .

8 thoughts on “Svn Bugzilla Integration

  1. Hi Simon,

    My vmware appliance where I had the thing configured refuses to come up. I’m still trying to fix it – so do check back in a few days.

    -R

  2. Hi

    Iam configuring rh9+scmbug+cvs+bugzilal 2.22.2, after installaing the daemon, is there any need to configure the glue for all the bugs, or its a one time process, iam a little bit confgused post installation of daemon, in my system daemon is working fine, but whats the next step, how to see the results
    hope there is some expert is ther on scmbug .. pl help me
    thanks in advance

  3. The glue installation basically configures a SVN repository with a Bugzilla product. Once you have installed the glue, you can edit the glue.conf file under the hooks folder to configure the behavior of the integration.

    To test, try a checkin some file without a bug, or with a bug assigned to some other user – you should get error messages similar to the ones in the article.

  4. Hi raghu
    Hope ur vmware is up and running, how to configure

    How to configure this part
    in daemon.conf

    # This is a one-to-one mapping of SCM usernames to
    # bugtracking usernames. Mappings in this list override
    # mappings from mapping_regexes.
    mapping_values => {
    enabled => 1,
    values => {
    ‘DOMAIN\\example_user’ => ‘example_user@DOMAIN.com’,
    ‘example_user2’ => ‘example_user2@exampledomain.com’

    i want to put a user like shaker, which should be pointing to username dchandrashaker@gmail.com in bugzilla, can u tell me the syntax. …..
    By seeing ur name , iam know ur indian or indian orgin, if ur in other country, where ur working .. just for curosity..

    have a good day
    with regards
    chandra shaker

  5. *******************************************
    2010/11/18 20:11:37 Scmbug WARN> Daemon.pm:81:Scmbug::Daemon::Daemon::read_configuration – Read configuration file ‘/etc/scmbug/daemon.conf’
    2010/11/18 20:11:37 Scmbug ERROR> Daemon.pm:114:Scmbug::Daemon::Daemon::read_configuration –
    *******************************************
    **
    **
    ** Scmbug error 79: Package ‘Bugzilla’ not found in installation directory ‘/usr/local/bugzilla-3.6.1/’.
    Initialization of bug-tracking system ‘Bugzilla’ version ‘3.0.0’ failed. This could be due to an unsupported version of this system, or misconfiguration.
    **
    **
    *******************************************

    Am facing this problem , FYI SVN & Bugzilla installed on one machine , its up and working fine. While am starting scmbug service above error come.
    Please suggest solution.

    Thanks in advance

  6. Resolved error 79 , now getting error as follows

    *******************************************
    2011/01/20 05:10:38 Scmbug WARN> Daemon.pm:81:Scmbug::Daemon::Daemon::read_configuration – Read configuration file

    ‘/etc/scmbug/daemon.conf’
    2011/01/20 05:10:38 Scmbug ERROR> Daemon.pm:257:Scmbug::Daemon::Daemon::check_configuration –
    *******************************************
    **
    **
    ** Scmbug error 44: Package ‘Net::LDAP’ is missing. It is required for SCM to bug-tracking username mapping using

    mapping_ldap.
    On a UNIX system, this package can be installed by running:
    perl -MCPAN -e ‘install Net::LDAP’;

    On a Windows system, this package can be installed by running:
    C:> ppm
    ppm> install Net-LDAP
    **
    **
    *******************************************

    Please suggest !!

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