Skip navigation

Community

T.C. Plomp's Blog

1 Post tagged with the rhodecode tag
0

This how-to describes how I have setup Mantis and Rhodecode to communicate with each other.

Mantis

Mantis Bug Tracker is a FOS (Free and Open Source) issue tracker widely used in the Open Source community running on PHP. John Reese has added a plugin category called Source Integration ( source). This offers several integration advantages between your preferred Source Control solution (Git(hub), SVN) and Mantis.

With this integration you can connect a commit/checkin/push to a specific issue (bug, feature, task) so you can track those. Using special commit messages it’s possible to change the status of issues to resolved.

Rhodecode

Rhodecode is a python-based local webservice for a set of Mercurial repositories built by Marcin Kuzminski. It has some nice features not found in the default Mercurial web-server:

  • Authentication based on LDAP
  • Private repositories
  • User-levels (admin, write, read, none)
  • Gravatar integration

Looking at the roadmap, Rhodecode wants to offer Git-hosting as well.
You can look at Rhodecode as a private/local Bitbucket version

Connecting Mantis with Rhodecode

The connection between Mantis and Rhodecode consist of two parts:

Mantis Source integration plugin

Prerequisite: Installed Source Integration plugins.

First part is an extension of the Source Integration plugin, you can download that from Bitbucket ( version 0.2.1), extract this plugin and copy the SourceRcWeb directory into the Mantis BT plugins directory and log-in to Mantis.

When you open the Manage Plugins page (http://% yourmantisURL%/manage_plugin_page.php) you’ll see a Rhodecode plugin in the available plugins list:

RhodeCodeAvailable

Now click the Install link, and the plugins is installed.
Proceed by going to the RhodeCode plugin configuration page (http:// %yourmantisURL%/plugin.php?page=SourceRcWeb/config):

  RCWeb_configuration

This dialog allows you to set a default URL for your repositories, this can be overwritten per repository.

Installing Rhodecode hook

Prerequisite: Installed and working Rhodecode setup.

Rhodecode supports the same hooks as Mercurial, however there is currently (version 1.1.8) not an integrated Web-UI way to setup hooks.

To install the hook script (located in the root of the download) you’ll need to edit the SQLite database file used by Rhodecode (rhodecode.db by default).

I used SQLite Database browser, and edited the rhodecode_ui table and added a record with the following contents:

  • ui section: hooks
  • ui key: changegroup.mantis
  • ui value: path of the changegroup file

The used changegroup file is the hook script. Make sure the script is executable by the user running Rhodecode (eg: www-data).

Adjusting Rhodecode hook

The Rhodecode hook uses curl to call the webinterface of Mantis, you’ll need to adjust it to math your situation.

#!/bin/sh
# Replace mantis with the URL of your actual mantis install
URL="http://mantis/plugin.php?page=Source/checkin.php"
PROJECT=${PWD##*/}
echo "Mercurial project: "$PROJECT
echo "Mercurial node: "${HG_NODE}
CURL=/usr/bin/curl
echo "Updating Changeset to Mantis Bug Tracker"
${CURL} -s  -S -d "repo_name=${PROJECT}" -d "data=${HG_NODE}" ${URL}

Line 3 contains the URL of you the checkin php script, make sure this is adjusted and accessible from the Rhodecode server. If you are running version 0.16.3 you’ll need to add  an API-key to the curl command ( info):

API_KEY="xxxxxxxxxx"
${CURL} -s -S -d "repo_name=${PROJECT}" -d "data=${HG_NODE}" -d "api_key=${API_KEY}" ${URL}

This hook is triggered every moment something is added to the repository and sends the information about the commit (project and commit-id) to Mantis.

Adding a repository to Mantis

Now everything is setup we’ll need to add the repository to Mantis.
There is one prerequisite to read the Rhodecode information, the repository needs to be readable by an anonymous user in Rhodecode, so you’ll need to configure Rhodecode to allow anonymous read for the given repository.

On the repositories page (http:// %yourmantisURL%/plugin.php?page=Source/index), there is an option to add a Rhodecode repository.

CreateRepo

Make sure the Name is exactly the name of your repository, after ‘Create Repository’ the following dialog opens.

UpdateRepository

The details from the generic configuration as well as the repository name are used to configure the repository. Per default there is no additional configuration necessary.

After this action you can use the Import Latest Data function to get all the information from Rhodecode:

Import-Latest

After these actions you have all the information  connected, you can browse in Mantis all your commits, their parents and connected issues.

Connecting a commit to an issue

Mantis filters the commit message to connect a commit to a specific issue.
Per default the following patterns are recognized:

  • issue #ddd
  • issues #ddd
  • bug #ddd
  • bugs #ddd
  • report #ddd
  • reports #ddd

To fix an issue the following patterns are accepted:

  • fixes #ddd
  • fixed #ddd
  • fix #ddd
  • resolved #ddd
  • resolves #ddd

ddd is the number of the issue, the hash (#) is mandatory. Look in the configuration of the Source Plugin to alter these patterns if you need that.

Result

What happens if you push something into Rhodecode, the hook will be triggered and you’ll see in the feedback from Rhodecode what Mantis is doing:

remote: Mercurial project: test
remote: Mercurial node: fe7fbe7c8644a6ff20f0ddf773c6e19eee6bc7dd
remote: Updating Changeset to Mantis Bug Tracker
remote: <pre>Retrieving test from  ... </pre>Retrieving fe7fbe7c8644a6ff20f0ddf7
73c6e19eee6bc7dd ... Processing fe7fbe7c8644a6ff20f0ddf773c6e19eee6bc7dd ... sav
ed.



Originally posted by TonPlomp at http://tononlabview.blogspot.com/2011/07/connecting-mantis-with-rhodecode.html