Mantis: SVN integration in 1.2.x

http://blog.crazytje.be/mantis-svn-integration-in-the-1-2-x/



Recently I upgrade my mantis version from 1.1.8 to 1.2.6, first thing I ran into was my SVN hook that didn’t work anymore.

In the 1.2.x they moved the checkin.php and implemented a fairly extensive plug-in system.

With the new 1.2.x mantis takes the source control integration a step further, it now natively supports source control integration and integrates nicely with WebSVN.

A few screenshot to show what they added:

 


 

Because of the integration with WebSVN, it allows for direct links to the diffs and modified files from within mantis.
So no need to look up changes manually anymore.

The downside is that the installation becomes harder. In the past it was calling the checkin.php script with a few parameters and that was it.

This has changed!

 

Installing WebSVN

I already went over how to install WebSVN here but to be complete I’ll go over it again.

For the WebSVN you’ll need svn(doh!) and a webserver like apachelighthttpd or IIS.

A short description taken from the Websvn website to explain what it does:

“WebSVN offers a view onto your subversion repositories that’s been designed to reflect the Subversion methodology. You can view the log of any file or directory and see a list of all the files changed, added or deleted in any given revision. You can also view the differences between two versions of a file so as to see exactly what was changed in a particular revision.”

To install WebSVN, follow these steps:

cd /path/to/websvn
cp include/distconfig.php include/config.php
vim include/config.php

Add repository path(s):

$config->addRepository('MyTestRepo, 'svn://example.com/myrepo)', null, 'username, 'password');

 

the addRepository can be used to add all kinds of repositories, see the config file for examples.
Go to “http://yourdomain.ext/websvn” and you should be able to view your repository.

My setup looked like this:

Installing the source control plug-ins

Now that we’ve got the prerequisites up and running it’s time to add the plug-ins we need to mantis.

We’ll need the following plugins:

  • Source Control Integration
  • Subversion Integration
  • Subversion / WebSVN Integration

They can be downloaded from here:
https://github.com/mantisbt-plugins/source-integration

Extract the file and copy the directories into your mantis plugins directory(modify the commands to suite your needs).

tar -xvf mantisbt-plugins-source-integration-release.....tar.gz
cp -R mantisbt-plugins-source-integration-release...../* /mymantisdir/plugins/

Log in on the mantis site, go to ‘manage’ and click ‘ Manage Plugins’.

You’ll see a list of plug-ins available for your installation.

Install the plug-ins in this order:

  1. Source Control Integration
  2. Subversion Integration
  3. Subversion / WebSVN Integration.

 

To configure the source control plug-in click the ” Source Control Integration 0.16.4″ in the first column of ‘Installed Plugins’

Here you can set your own preferences.

Check the ‘Enabled Features’ checkboxes and change the regex’s if you want. I changed mine to those I was used to:

Bug Link Regex Pass 1: /\b(?:bug|issue|task)\s*[#]{0,1}(\d+)\b/i
Bug Fixed Regex Pass 1: /\bfix(?:ed|es)\s+(?:bug|issue|task)?\s*[#]{0,1}(\d+)\b/i

 

Create an api key and fill it in by running:

openssl rand -base64 12

 

‘-hex’ is also ok, but that didn’t work for me.

At the bottom don’t forget to enter the path to your svn binary, on linux this is most of the time /usr/bin.

 

Adding a repository

You’ll see a new link popping up in the menu called “Repositories”, click it and add your repositories.

Enter a name for the repository you’d like to add, select WebSVN and press ‘Create Repository’.

For the params you need to fill in:

  • URL: this is your svn url, example: svn://example.com/
  • WebSVN URL: this is where websvn is installed, example http://example.com/websvn
  • WebSVN Name: This is the name used for this repository in WebSVN(must match!)
  • SVN Username & Password: fill in the username and password for the svn user
  • Standard Repository: check this if you use a ‘trunk/branch/tag’ structure
    If you do not the default trunk/branch/tag structure you’ll need to fill it in, else leave them blank.

Once filled in, press ‘Update Repository’. The page you’ll see next gives you the option to import the latest data or everything.

Be careful when importing, this will react on the ‘fixed issues’ in the commits, add the notes and send out mails!

 

Pushing Commits to Mantis

There is one more step to do. That is pushing svn commits to mantis.

This is still done with a svn post-commit hook.

There is a post-commit script already available in “/mantis/plugins/SourceWebSVN/post-commit.tmpl”

Copy this script to your svn hooks directory and remove the .tmpl.

Modify the script to suite your needs, for most people changing the URL and PROJECT variable should do the trick.

Don’t forget that the ‘PROJECT’ needs to be the same name used as repository title in mantis!

REV="$2"
 
URL="http://localhost/mantisbt/plugin.php?page=Source/checkin"
PROJECT="Repository Name"
LOG_FILE=`mktemp /tmp/svn_${PROJECT}_${REV}_log.XXX`
CURL=/usr/bin/curl
 
${CURL} -d "repo_name=${PROJECT}" -d "data=${REV}" ${URL} >> ${LOG_FILE}

The result should be that you can commit and the changeset together with the resolving/adding a message to an issue.

Example(depends on regex and template message settings):

svn commit -m 'fixed issue xxx'

Results in:

Note that the message displayed in the screenshots above are from a modified Mantis version.

More info on getting the author and revision changes to be shown can be found here:
Mantis SVN Integration : Adding extra info to the Note

And that’s how you set up the SVN integration with mantis.
It’s worth the extra effort, because mantis plays really nicely together with WebSVN.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值