Source Control Integration for Mantis 1.2.X

Mantis is an open source bug/feature tracker. For documentation purposes it is sometimes necessary to check which bug/feature was resolved in which svn commit. Furthermore the workflow for a ticket can be automated (e.g. change of the status).
1 answer

Add Source Control Integration to Mantis 1.2.X

Due to the lack of a built in solution or a (simple) plugin which connects a SVN-repository and Mantis, the connection of these two system could be a bit tricky.

Preconditions

  1. Install an Ubuntu 12.04 LTS
  2. Install SVN
  3. Install WebSVN
  4. Install Mantis 1.2.X
    1. Install Source Control Integration plugin
    2. Install Subversion Integration plugin
    3. Install Subversion / WebSVN Integration plugin

These system could be but must not be on the same host.

Configuration SVN
Add a post commit hook to your SVN-repository with the following code:

#!/bin/sh
REV="$2"

URL="http://mantis.example.com/plugin.php?page=Source/checkin"
PROJECT="ProjectName"
CURL=/usr/bin/curl

${CURL} -d "repo_name=${PROJECT}" -d "data=${REV}" -d "api_key=4289def1asdc402abf71de1d" ${URL}

Configuration WebSVN
Add the repository to WebSVN, which is use to see the source of the code and the diffs of the commits.

  1. Change file:

    PATH_TO/websvn/include/config.php
  2. Add to file:

    $config->addRepository('$NAME', 'svn://URL_TO_REPOSITORY', null, '$SVN_USER', '$SVN_PASSWORD');

    $NAME ... the repository name
    $SVN_USER ... the username of a svn user
    $SVN_PASSWORD ... the password of an svn user

Configuration WebSVN
Add the repository to Mantis.

  1. In Mantis klick on Repositories in the Menubar
  2. Add the Name of the Repository (the same name which was used in WebSVN)
  3. Choose webSVN as Type
  4. Klick Create Repository
  5. See attached screenshot for further repository properties

Commit message commands

  • use "issue $TICKET_NUMBER" to assign a ticket to a commit
  • use "#fixes $TICKET_NUMBER" to set the status of a ticket to resolved

Taggings: