## Integrating Mantis and Subversion

Posted by Tom on November 29th, 2006

Do you want to know how to integrate Mantis and SVN? I did, but could never manage the right Google query to return a page written for someone unfamiliar with customizing Mantis. (I’m still learning SVN too.) This is the documentation I wish I’d had. This process is easier if you know Bash or some other scripting language. This was accomplished using Mantis 1.0.0rc2. An older version may not work with these instructions.

### Introducing Subversion (SVN) Hooks

Subversion allows for custom scripts to be called when it performs certain actions on a repository. Browse to your repository. The server-side one, not your working copy. In /path/to/svn/repository_name/hooks you will see a list of sample scripts for the five actions subversion recognizes.

start-commit
Run before the commit transaction is created. May be used to stop the transaction and return error messages to clients.
pre-commit
Run when the transaction is complete, but before it is committed. It can be used to require comments to include a bug tracker ticket number, or enforce fine-grained access to parts of the repository. It can cause the transaction to rollback and return error messages to clients.
post-commit
Run after the transaction is committed, and a new revision is created. Often used to send notification emails or trigger repository backups. Errors from this hook are ignored Subversion comes with some scripts for common actions. Read the manual for more details.
pre-revprop-change
Revision properties such as log messages aren’t versioned. If you were to go back and change a log message, for example, the old one would be lost. This hook, and its post- counterpart, offer a chance to reject or log the change.
post-revprop-change
Run after revision properties are changed. There are some security restrictions built in, be sure to read the manual.

Well, that sounds simple. All we have to do is write a script that will log into our bug tracking system and insert a comment on the appropriate ticket. That sounds easy enough, but let’s not make things too complicated. With a few minor customizations, Mantis will do most of the work for us.

### Customizing Mantis

The manual for Mantis has two relevant pages. One, titled “Source Control Integration”, provides a list of customizable settings, but offers no directions on where these settings are most appropriately accessed. The other, “CVS integration”, is not terribly helpful either, but it does provide another piece of our puzzle—it tells us there is a command line PHP script included with Mantis that accepts a version control (e.g. SVN, CVS) log message via stdin, and adds comments to any tickets as appropriate.

First things first. Create a new user in Mantis. This is the account the script will use. I called mine “svn”. Make sure the user has permission to add comments and resolve tickets. Don’t forget to add it to your project(s).

Open up /path/to/mantis/config_inc.php. If it doesn’t exist, create it. (If it doesn’t exist, you didn’t follow the installation directions.) This file is used to override default settings. It’s not distributed as part of Mantis, so when you upgrade, it won’t be overwritten. This is where you should have your database connection information, and where you would override the default colors, status/severity options, or any number of configurable settings.

Add the following lines to /path/to/mantis/config_inc.php:

$g_source_control_account = 'svn';$g_source_control_regexp = '/\b(?:bug|issue)\s*[#]{0,1}(\d+)\b/i';

What does it all mean? (Some credit is due Digitalpeer for helping me through this. I found it just as I was getting the integration working. It would have saved some time.)

$g_source_control_account This is the user we created in Mantis. $g_source_control_regexp
This is the regular expression Mantis will match against the log message. This is an optional setting; the default is /\bissue [#]{0,1}(\d+)\b/i.

#### Using a custom RegExp

You’ll notice I defined a regular expression different from the default. I wanted to not only match the string “issue #1337″, but to be a bit more liberal, matching the phrase “bug #1337″ too. For those of you savy enough to craft your own expressions, the first capturable group must be the bug number, or the script won’t work. (This is hard-coded into Mantis.) Hence the non-capturing group (?:bug|issue).

#### Automatically closing tickets

These custom settings lay the groundwork for Mantis to automatically add comments to tickets based on SVN log messages. There are additional settings we can use to get Mantis to resolve tickets automatically too, based on a different regular expression. To enable this behavior, add the following lines to /path/to/mantis/config_inc.php:

$g_source_control_set_status_to = RESOLVED;$g_source_control_set_resolution_to = FIXED; $g_source_control_fixed_regexp = '/\bfix(?:ed|es)\s+(?:bug|issue)?\s*[#]{0,1}(\d+)\b/i'; $g_source_control_set_status_to
The status to set the ticket to. Use CLOSED if you prefer.
$g_source_control_set_resolution_to The resolution attached to the ticket. There are constants defined for each built-in resolution. You may use a different one, but FIXED makes the most sense. $g_source_control_fixed_regexp
This is an undocumented setting. The default is to be equal to $g_source_control_regexp, but I only wanted certain tickets to be automatically closed, so I used a different regular expression. My expression matches “fixes issue #1337″, “fix bug #1337″, or simply “fixed #1337″. (Plus several iterations on those words.) The ticket number must be the first captured group. Altering the expression to also accept the words “solved” and “solves” is left as an exercise for the reader. #### Testing Mantis Before we go further, let’s make sure we implemented the Mantis settings properly. Run the following from the command line (alter the paths, of course) %> /path/to/php /path/to/mantis/core/checkin.php <<< "My web monkey fixed issue #1337 by accident." If you’ve configured Mantis correctly, there should be a new comment on ticket #1337. ### Connecting the pieces Now that we have Mantis set to accept log messages from our version control system, we need to connect Subversion to it. Remember the hooks from the beginning of this article? We’re going to write one. I used Bash script. (Be nice, I’m still learning Bash.) Save the following file to /path/to/svn/hooks/post-commit (no file extension): #!/bin/bash REPOS="$1" REV="$2" log=$(svnlook log -r $REV$REPOS)   /usr/bin/php -q /var/bugtracker/core/checkin.php <<< "$log" #### What is svnlook? The program svnlook is distributed as part of Subversion. Given a revision and repository path as parameters, it will return various properties of the revision, such as the author or which files were changed. In this case we’re asking only for the log message. #### Permissions Give the file permission to executable by your repository. This will be slightly different for each setup, but something similar to the following should do the trick: %> cd /path/to/svn/hooks %> chmod 770 post-commit %> chgrp svn post-commit #### More on post-commit The post-commit hook takes two parameters: the repository path and the revision number. If you needed to run post-commit manually (testing your script!), it would look something like this for revision 746: %> /path/to/svn/hooks/post-commit /path/to/svn/repository_name 746 ### SVN and Mantis in perfect harmony There you have it. That’s how you integrate Subversion with Mantis. If you have questions, feel free to leave a comment. Special thanks to the guys who spent time writing Version Control with Subversion (For Subversion 1.1): Ben Collins-Sussman, Brian W. Fitzpatrick, and C. Michael Pilato. The world would be a better place if every piece of open source software was documented this well. (By contrast, the Mantis documentation is terribly out of date and rather disorganized.) #### A more advanced script I wasn’t content with having just a log message added to my Mantis tickets. I wanted to know who did it, and what files were changed. Thus, my actual script is a bit more complicated. (Remember, I’m still learning Bash, so be nice.) #!/bin/bash REPOS="$1" REV="$2" auth=$(svnlook author -r $REV$REPOS) dt=$(svnlook date -r$REV $REPOS) changed=$(svnlook changed -r $REV$REPOS) log=$(svnlook log -r$REV $REPOS) n=$'\n' /usr/bin/php -q /var/bugtracker/core/checkin.php <<< "Changeset [${REV}] by$auth, $dt$n$log$n$changed" Be Sociable, Share! ## 139 Responses to “Integrating Mantis and Subversion” Gave this a try this morning. Very cool. Thanks for this. However, when I try and run the test: /path/to/php /path/to/mantis/core/checkin.php [...] Integrating Mantis and Subversion I want to get a setup like this running reasonably soon, for tracking a few personal bits of stuff. So here’s a guide. (tags: development) [...] Thank you so very, very much for this. While the process makes lots of sense, the documentation on the mantis manual only serves to INCREDIBLY confuse you. :/ Thanks for this excellent page ! I configure the SVN-Mantis integration fingers in the nose :D [...] Integrating Mantis and Subversion [...] Thanks so much for this. Thanks you so much! I’ve been delaying to integrate SVN with Mantis for weeks now, simply because from some first research I knew it would be quite a hassle. Today I decided to finally tackle it and luckily I researched again and found your blog entry. It saved me a lot of time, thank you very, very much for this! Forgot to mention that I found you via the Mantis manual: http://manual.mantisbugtracker.com/manual.configuration.source.control.integration.php Thanks again, you’re my hero! :D Dear Sir, Need help… I have Mantis and SVN installed on my machine (Windows. I want to integrate it. I scratched my head for a long time now.. need your help.. If you could help me in giving simpler steps.. that would be great help.. I have php as well i installed activeperl… Help Thanks in advance Regards sandeep @sandeep: I don’t have an SVN server installed on my Windows machine, and don’t have a reason to. A few simple Google searches suggest you’d have to write batch scripts (.bat) or .exe files instead of bash scripts like I’ve done here. One of the Google results returned demonstrated someone who installed Perl on Windows, then wrote a batch script to call a Perl script. Your mileage may vary. The site looks great ! Thanks for all your help ( past, present and future !) Hey guys.. Thanks.. This is a very very useful document.. I could manage the windows based as well Linux based Mantis + SVN integrationg working… And it looks fantastic… Thanks again… Regards sandeep [...] 在 Mantis 的文件網站找到了這個 Link : Integrating Mantis and Subversion [...] thank you very much :-) [...] 7. 활용 – Mantis 기능으로 DocuWIKI 연결, CVS/Subversion 연결, Eclipse 연결 모듈과 연동할 수 있음. – Config 설정 : Mantis config에 대한 설명은 http://www.mantisbt.org/manual/manual.configuration.php 참조 – Mantis – Subversion 연동은 http://alt-tag.com/blog/archives/2006/11/integrating-mantis-and-subversion/ 참조 [...] This is many many times better than any other resource on how to do this, got it working in minutes. Many thanks. […] 在 Mantis 的文件網站找到了這個 Link : Integrating Mantis and Subversion […] You are a legend mate! Thanks very much [...] Integrating Mantis and Subversion [...] Hey ! Seems to be a very nice work, but I can’t use it. Actually, I have neither ticket #1338, nor comments on it. However, I’m using a Mantis administrator account, under RHEL 4, and am working on my localhost ;p. I don’t really understand my mistake. Can somebody help me ? I run in the command line: > /path/to/php /path/to/mantis/core/checkin.php “I resolved issue #2″ But I get this error: “Comment does not reference any issues” I can’t understand why! I have got issue #2 in Mantis. I also tried #0000002, but didn’t work. Any suggestion? Hi first want to thank you for the work you did but i have a problem i come to the step where i work with the bashscript. its similar to yours just the path is different form mantis. if i execute it i get the following msg. from snv look: svnlook: Can’t open file ‘testprojekt/format’: No such file or directory do you maybe know whats the reason for this? First, thank you for the excellent guide. Second, notes default to private, otherwise add this to your config.$g_source_control_notes_view_status = VS_PUBLIC;

[...] Hier gibt es ein detailliertes How-to für die Integration von Subversion und Mantis. Dann können z.B. Tickets in Mantis automatisch durch entsprechende Einträge im Subversion-Log geschlossen werden. [...]

[...] Re: Subversion Repository There is quite a nice article on Mantis hooks here, in case its of any interest alt-tag.com Blog Archive Integrating Mantis and Subversion [...]

Thanks for that article.
Here is a WINDOWS equivalent.

— POST-COMMIT.BAT ———-
@ECHO off

SET REPOS=%1
SET REV=%2

SET PHP=C:\….\php.exe
SET CHECKIN=C:\….\mantis\core\checkin.php
SET SVNLOOK=C:\….\bin\svnlook.exe

SET LOGFILE=log%REV%.txt
SET AUTHORFILE=author%REV%.txt
SET OUTPUTFILE=output%REV%.txt

%SVNLOOK% log -r %REV% %REPOS% > %LOGFILE%
%SVNLOOK% author -r %REV% %REPOS% > %AUTHORFILE%

ECHO SVN %REPOS% Revision %REV% > %OUTPUTFILE%
TYPE %AUTHORFILE% >> %OUTPUTFILE%
TYPE %LOGFILE% >> %OUTPUTFILE%

TYPE %OUTPUTFILE% | %PHP% %CHECKIN%

CALL DEL %LOGFILE%
CALL DEL %AUTHORFILE%
CALL DEL %OUTPUTFILE%

— / POST-COMMIT.BAT ———-

Thank you Tom for the excellent article.

Paul, also thanks you as your post-commit file let me get up and running!

Hello,
I have svn running on Linux, and Mantis is running on another computer, under Windows 2003 OS.
Does someone know how I could make the link between the two systems ?

[...] Ideal Build System Posted on September 28, 2007 by Reiot integrating-mantis-and-subversion을  보고, 이상적인 통합 개발 지원 시스템에 대해서 생각해봤다. 일단 맨티스에서 버그는 물론 new feature (or issue, whatever)를 관리한다고 가정하면, [...]

Thanks a lot – worked perfectly for me.

Great work!

Hi – I did the basic config in my mantis (i.e set the 2 variables g_source_contol_account and g_source_control_regexp see below). Then before continuing I did the test – Every time i get “Comment does not reference any issues.”

command is /php /core/checkin.php

Tried this out locally, and it works slick. Our problem is that we’re using Sourceforge’s SVN system for the project I want to track. Has anyone gotten this to work using the SVN hooks that sourceforge makes available?

Best,

Perry Clark

This worked like a charm!
However the regexp for fixing bug/issues didn’t work for me.
A slight modification made it work:
‘/\bfix(?:ed|es)?\s+(?:bug|issue)?\s*[#]{0,1}(\d+)\b/i’;

[...] Also, there are lots of other interpretations of what it means to integrate Mantis and Subversion. One of the more pervasive currents seems to be to automate the interaction between Subversion commits and Mantis issue updates, as elucidated in detail here. This is interesting, but not what I had in mind. I want to view the source code changes that correspond to issues in a simple way. [...]

[...] alt-tag.com » Blog Archive » Integrating Mantis and Subversion (tags: mantis subversion svn bugtracking integration development howto programming environment) [...]

Perhaps this would be of some additional interest:

http://blog.evaristesys.com/index.php/2007/10/18/integrating-mantis-viewvc-subversion-for-source-code-view-a-minor-hack/

Hi, I´m from Brazil, and I need so much a manual or anything step-by-step about integration Mantis with SVN in Windows…please this is an SOS :S
tks a lot

Great howto, thanks a lot for writing it down!

>Hello,
>I have svn running on Linux, and Mantis is >running on another computer, under Windows >2003 OS.
>Does someone know how I could make the link >between the two systems ?

>Left by Sebastien Roy on September 19th, 2007

I have this same setup working.
I installed freeSSHD on the windows server.
I modified the checkin.php script to read its input from the command line instead of from STDIN.
Then I call it with

ssh svn@mantis.myco.com “c:\\php\\php.exe -q path_to_checkin2.php \”args_from_above_example\”"

in the post-commit script.

In this setup I have public-key login working so no passwords are needed.

Hi.
Good design, who make it?

Hi,

I’m trying to get this working on to different win servers. When I try the checkin.php localy it works. But when I use pauls *.bat file nothing happens on Mantis.

I have on the Subversion server mapped the disc with the folder for php and mantis so a can reach them on from Subversion server.

the bat file looks like this:
@ECHO off

SET REPOS=%1
SET REV=%2

SET PHP=Y:\php.exe
SET CHECKIN=Z:\core\checkin.php
SET SVNLOOK=C:\Program Files\Subversion\bin\svnlook.exe

SET LOGFILE=log%REV%.txt
SET AUTHORFILE=author%REV%.txt
SET OUTPUTFILE=output%REV%.txt

%SVNLOOK% log -r %REV% %REPOS% > %LOGFILE%
%SVNLOOK% author -r %REV% %REPOS% > %AUTHORFILE%

ECHO SVN %REPOS% Revision %REV% > %OUTPUTFILE%
TYPE %AUTHORFILE% >> %OUTPUTFILE%
TYPE %LOGFILE% >> %OUTPUTFILE%

TYPE %OUTPUTFILE% | %PHP% %CHECKIN%

CALL DEL %LOGFILE%
CALL DEL %AUTHORFILE%
CALL DEL %OUTPUTFILE%

Can someone please point me in a direction where to start look for errors?

Great stuff!

Is it possible to set these config variables through the new Mantis “Manage Configuration” options screen? Would be nice not to have to go edit .php files.

What if my mantis DB is on an external, password-protected server?

Using mantis and SVN on different machines makes using the checkin.php script hard.

I’ve created a copy of the script checkincurl.php

this checks for a ‘log’ field in a posted form and checks that the originating ip is the SVN machine.

the command to make this work on the SVN is something like this:

curl -k -d “$log” Hi I have some problem to integrate svn with mantis I ‘ve created post-commit.bat. All my data are in my log file but when I want ta put this data in my mantis database nothing appears. I show you my code D:\Program Files\wamp\php\php.exe D:\Program Files\wamp\www\mantis1.0.7_GTE\core\checkin.php Works great, right out of the box so to speak. I did run into a minor glitch running the checkin.php script from the command line: If your mysql.sock isn’t in /tmp, this won’t work. Adding the following line to checkin.php will fix the problem (since this script can’t be called from the browser, this change shouldn’t conflict with browser-based Mantis functionality): ini_set(“mysql.default_socket”,”/var/lib/mysql/mysql.sock”); P.S. This tip was shamelessly stolen from a suggestion in the Mantis docs which I can’t seem to find at the moment… I am trying to get this to work but the test line php checkin.php I am trying to get this to work but I get a Segmentation Fault from checkin.php if a valid issue number is provided. If you get the “Comment does not reference any issues” error when testing the settings: check your double-quotes. If you copy-pasted it’s likely you entered the command with curly quotes instead of straight ones, thus the input comment is only parsed up to the first whitespace. Fantastic article. Hope there will be an easier way of integrating them… The notes works perfectly but the status and resolved changes didn´t worked for me. I copied the E.R exactly from the article and tried doing some changes but all whith no success. Anyone could help me ? [...] Co dalej? Jeżeli programujemy, prawdopodobnie przyda się nam bugtracker. Na naszej nieurodzajnej ziemi dobrze przyjmie się na przykład Mantis (wymaga PHP i MySQL) – świetny system, który łatwo możemy zintegrować z naszym repozytorium. Szczegółowy opis, jak można coś takiego zrobić, znajduje się na blogu alt-tag. Niezłą alternatywą, zarówno wobec WebSVN i Mantisa, jest np. oparty na Pythonie system Trac. Ma on jednak pewne wymagania, które nie każdy serwer musi spełniać. [...] Humm great ! After some tests, I have noticed some problems with checkin.php : seem only accept UTF8 input. If the varible$t_comment is not UTF8 encoded, the script crash with “APPLICATION ERROR #401″.

After some string conversion , the integration run really great.

Tests with Mantis 1.1.1 under Win32 and Linux.

Hi, I have not tried to integrate Mantis with Subversion yet, but this article looks as if it will help a lot. Before I start integrating I would like to know if it is possible to populate the version list in the Mantis “Report Issue” screen from the versions available in Subversion? Thanks

Hi. I tried to integrate Mantis with Subversion and I need for help.
I did the initial configuration and I execute the line command:

c:/wamp/php c:/wamp/www/mantis/core/checkin.php

[...] MantisBT & Subversion [...]

Comment does not reference any issues

./config_inc.php
$g_source_control_account = ‘svn’; #$g_source_control_regexp = ‘/\b(?:bug|issue)\s*[#]{0,1}(\d+)\b/i’;
$g_source_control_set_status_to = RESOLVED;$g_source_control_set_resolution_to = FIXED;
#$g_source_control_fixed_regexp = ‘/\bfix(?:ed|es)\s+(?:bug|issue)?\s*[#]{0,1}(\d+)\b/i’; But when I run php ./core/checkin.php I followed all your steps and i do understand the process, im running svn and mantis on CentOS5, they’re both set up fine and working but i cant seem to integrate them together after doing all the steps 1. I get ‘permission denied’ when I run the test: %> /path/to/php/path/to/mantis/core/checkin.php chgrp svn post-commit does not also work, is says invalid group svn 3. lastly, i can’t seem to test the bash script %> /path/to/svn/hooks/post-commit /path/to/svn/repository_name 746, it just says that the repos name i am pointing to is a directory thanks in advance! any help would be much appreciated :D Hi. I tried to integrate Mantis with Subversion and I need for help. I did the initial configuration and I execute the line command: c:/wamp/php c:/wamp/www/mantis/core/checkin. php (Continuing…) My command line is: c:/wamp/php c:/wamp/www/mantis/core/checkin. php > was unexpected at this time” Someone can help me? Thanks. I’m Sorry, but my messages are being cut. When I execute this command: c:/wamp/php c:/wamp/www/mantis/core/checkin. php Just wanted to say thanks, you helped me out a great deal with this blogpost! I now have Mantis/SVN working in sync! :) [...] You will need to modify your Mantis’ config_inc.php a bit. I found these lines of code from this guy who last year helped us all integrate a local mantis to a local svn repository. Add the following lines: [...] [...] And I work with several ticketing systems, so I’m not at all intimidated by them. I looked at the Dreamhost wiki to see what other people are using… the packages were all familiar, but there aren’t any that are auto-installed. Mantis of course strikes my fancy. Clean and lean but still robust and intuitive. Software written by people who depend on it is a beautiful thing. And I found some great instructions explaining exactly how to integrate mantis and subversion. Happiness ensues! [...] Thanks – seems to work great. I use Dreamhost for mantis and svn hosting and was able to quickly follow these instructions with no problems so far. Trying this on the packages that come with fedora 9. the php checkin.php test in the command line does not work. There is no error message at all. even if I do not feed in any text…. does anybody have an idea what might be wrong? If your server is Windows and using Tortoise SVN this user note at the Mantis site worked first time for me. Includes the source code changes in the note and more impotantly the revision number so I know what to roll back to if I have to. http://manual.mantisbt.org/manual.configuration.source.control.integration.php#419 @ECHO off SET REPOS=%1 SET REV=%2 SET PHP=C:\….\php.exe SET CHECKIN=C:\….\mantis\core\checkin.php SET SVNLOOK=C:\….\bin\svnlook.exe SET LOGFILE=log%REV%.txt SET AUTHORFILE=author%REV%.txt SET OUTPUTFILE=output%REV%.txt %SVNLOOK% log -r %REV% %REPOS% > %LOGFILE% %SVNLOOK% author -r %REV% %REPOS% > %AUTHORFILE% ECHO SVN %REPOS% Revision %REV% > %OUTPUTFILE% TYPE %AUTHORFILE% >> %OUTPUTFILE% TYPE %LOGFILE% >> %OUTPUTFILE% TYPE %OUTPUTFILE% | %PHP% %CHECKIN% CALL DEL %LOGFILE% CALL DEL %AUTHORFILE% CALL DEL %OUTPUTFILE% When I try to use this post-commit script it gives syntax error, I do not know to write batch scripts so i cannot understand what’s wrong with this code? Could someone help? Work absolutly great… Thanks a million for the howto… it was a great help… :D Wish it could be done for a seperate server solution where SVN and Mantis are not on the same box… Willem, that shouldn’t be too difficult to do, but it would be inherently unsafe: If you use TortoiseSVN as a client, you can install _client_ side hooks since v1.5. With this, you have two options: 1.) Specify a script that uses tools like wget to simulate a web site access to update the issue 2.) Use the mantisconnect.php SOAP API to update the issue. Both ways, there’s a serious security issue: Since the client has to access the mantis issue, it will have to provide credentials and you’ll have to store them on the client. That way, anyone with access to the client can go and (depending on which mantis account you use, a generic “svn” one or your personal account) update/close all the bugs. Now i store my svn password with tortoiseSVN in my windows/documents folder, but at least, it’s scrambled. You would have to implement this on your own for the solution suggested above to provide minimum security. Of course, the mentioned setup is for a configuration where you don’t have admin access to the subversion server (which is the case here). If you have that access, it should be easy to setup ssh as Morris stated above and remote execute the checkin.php Hi! I followed all your steps and i do understand the process, but i cant seem to integrate them together after doing all the steps… I get ‘permission denied’ when I run the test “%> /path/to/php /path/to/mantis/core/checkin.php _ You may want to have a look at Scmbug: http://freshmeat.net/projects/scmbug/ It already does all this and much more. Hi, thanks, it works great. One additional note about PERMISSIONS: I use svn in combination with apache. Therefore I had to give the user “www-data” executable rights to the file post-commit. [...] Integrating Mantis and Subversion [...] A simple change in core/checkin.php will let you have the notes added as the user that committed the change. In my environment user account names are identical between Mantis and subversion so this works very well. Change (approximately) line 40 from:$t_username = config_get( ‘source_control_account’ );

to:

$t_username =$argv[1];

Now when you call checkin.php pass in the author as the first command line argument:

auth=$($SVNLOOK author -r “$REV” “$REPOS”)
dt=$($SVNLOOK date -r “$REV” “$REPOS”)
changed=$($SVNLOOK changed -r “$REV” “$REPOS”)
log=$($SVNLOOK log -r “$REV” “$REPOS”)

/usr/bin/php -q /usr/local/mantis/core/checkin.php “$auth” Hi my fiends, i have mantis and subversion installed on two different server, to integrate both, what kind of way ı should follow ?, any help would be appreciated as a plus, i have admin access on both server. hi my friends, i have one other question,if i want to access mantis on linux server, is there any way to connect corresponding server by using ssh with password,by the way my aim is to execute checkin.php on mantis server. thanks This tutorial helped me alot but I have been struggling to get this to work. Spent atleast 6 hours to find a fix and thought I would share it. My problem was that the commit succeeded without error. But it looked like the post-commit script was never run. The script ran perfectly when started by hand. Then I read on some page that when svn runs post-commit it doesnt have all the ENV settings. Slowly by testing the script I found out that svnlook couldnt be executed unless I added its path. So I changed: log=$(svnlookg …. to log=$(/usr/local/bin/svnlook …. ) and voila .. Perfect harmony! Might be worth a note in the tutorial ;) Hi this tutorial is very good And i try to integrate svn to mantis But i have an error that i can resolve and need a help In my svn hooks if i want to do #!/bin/bash REPOS=”$1″
REV=”$2″ log=$(/usr/bin/svnlook log -r $REV$REPOS)

/usr/bin/php -q /usr/share/mantis/www/core/checkin.php

But i get error

post-commit: 9: Syntax error: redirection unexpected
help me
thanks

you have to supply a log message to checkin.php;
for example, at the very end of the line add the followings;

/usr/bin/php -q /usr/share/mantis/www/core/checkin.php

Anyone knows if is possible to configure a pre-commit hook only for some Repository, I don’t want to have this validation for all svn repository. If yes, conf lines for this ?

frederick, what do you mean “some repository”, you mean a specific path in a repository ? if so you may edit pre-commit hook such that you can get the path of committed file by svnlook in phyton or whatever scripting language you are using, and control it, if the path is not what you want then ignore it. but as far as ı know svn does not have a mechanism that pre-commit hook does nt work for a specific path in the repository.

[...] En alephsa llegamos a integrarlo con nuestro ciclo de desarrollo de tres maneras: primero con notificaciones a los desarrolladores via email de los bugs (obvio, aunque no tan obvio en un proyecto de varios millones de dolares…), luego con un script (hook) de subversion que actualiza los tickets cuando se realiza un commit y finalmente notificando a los usuarios de la actualizacion del ticket. Ahora tambien me parece obvio que asi sea. La informacion de como integrar Mantis con Subversion esta disponible en este gran post de Tom Gregory. [...]

Hi Gregory,

It’s me Again, thank you for the two last helps. We are already using Mantis integrated with SVN in our company and it’s in Production.
Now I have to prepare a presentation to the Senior Managers about this integration and also the integration with our Task Management System.
The presentation is almost finished but I want to highlights some Benefits of this integration, could you please help me identify some Great Benefits and Advantages of SVN+Bug Tracking System Integration?

Thank you

Frederick

Thanks all for the wonderful help!

http://www.mantisbt.org/bugs/view.php?id=10160

We modified this ideea to add Time Tracking as well, because it is needed. Hope this help.

Updated the tutorial based on this and added time tracking.
http://www.grafxsoftware.com/option.php/182/

Worked like a charm… THANK YOU!

Hello
Could you help me integrate SVN and mantis please ?
I followed the steps you describe but when I try to check with this command :
C:\>C:/Serveur/PHP/php-5.2.9-Win32/php-cgi.exe C:/Serveur/CollabNet Subversion Server/httpd/htdocs/mantis/core/checkin.php ‘issue #1′

Nothing happens (no comment in Mantis)…
I only have :
X-Powered-By: PHP/5.2.9
Content-type: text/html

Could tou help me ?
Thanks

Those regular expressions do not work on Windows. Will be back with good ones when I figure them out.

Hi my fiends, I have mantis and subversion installed on two different server, to integrate both, what kind of way I should follow ?, any help would be appreciated

dude, amazing! you saved me HOURS today! thanks for the fantastic tutorial!

It works. But i had to use fixed paths in my hook scripts.

Thanks!

I have a fix for windows for the checkin.php script. In checkin.php there is a while loop:
while ( ( $t_line = fgets( STDIN, 1024 ) ) ) {$t_comment .= $t_line; if ( preg_match_all($t_commit_regexp, $t_line,$t_matches ) ) {
for ( $i = 0;$i

Comment got cut off. I’ll try to find another way to post all the fix info.

thanks for manual! i have now made bridge to mantis working :)

The only thing: in mine setup mantis have installed on one server, and svn on another.
Since checkin.php doesn’t allows to run it via webserver, i have made simple gateway script:

and put it in root of mantis (called as checkin-gw-ah345hiugh.php, where ah345hiugh is secret code :))

and in post-commit hook, instead of
/usr/bin/php -q /var/bugtracker/core/checkin.php

ugh… script eaten… inside php tag put code:
================
ob_start();
unset($_SERVER['SERVER_PORT']); define(“STDIN”, fopen(‘php://input’,'r’)); require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ‘core/checkin.php’ ); ================ And call it via curl http://mantis-path/checkin-gw.php –data-binary @- instead of php code/checkin.php Excellent article. Helped us a lot. Thanks I test mantis and get this error…I’m using CentOS release 5.2 and mantis-1.1.7 # php /usr/local/apache/htdocs/mantisbt/core/checkin.php Fatal error: Call to undefined function mysql_connect() in /usr/local/apache/htdocs/mantisbt/core/adodb/drivers/adodb-mysql.inc.php on line 364 If you are using Windows you can do the following to test the Mantis configurations: -creat a text file and name it “arg.txt” -in command line run: \path\to\php \path\to\mantis\core\checkin.php \path\to\atg\arg.txt Oops I forgot to tell write the following text in the arg.txt file My web monkey fixed issue #0001 by accident. @datacompboy Thanks for your gateway script. You could generate a GUID for a more secure filename, but it’s still risky. Mantis now (I saw it in 1.1.8) comes with a script core/checkincurl.php instead of checkin.php, which allows integration if your Subversion and Mantis are on different servers! Thanks for your comment Martijn! Can I ask the procedures/steps on how to integrate the SVn and Mantis on different machines (all both running in Windows). Thanks! Good posting. I jz want to add a little. Sometimes, the scripts provided up there cant work well. #!/bin/sh REPOS=”$1″
REV=”$2″ auth=”$(/opt/CollabNet_Subversion/bin/svnlook author -r $REV$REPOS)”
dt=”$(/opt/CollabNet_Subversion/bin/svnlook date -r$REV $REPOS)” log=”$(/opt/CollabNet_Subversion/bin/svnlook log -r $REV$REPOS)”
changed=”$(/opt/CollabNet_Subversion/bin/svnlook changed -r$REV $REPOS)” border=”==============================================================================” n=$’\n’
echo “Revision [${REV}] by$auth, $dt$n$log$n$border$changed$border” | /usr/local/apache2/php/bin/php -q /etc/opt/CollabNet_Subversion/default-site/htdocs/mantis/core/checkin.php Hope it helps some of you… :D cheers!!! [...] Integrating Mantis and Subversion – alt-tag.com (tags: svn mantis) [...] Hello, I think there is a security hole in the post-commit script. Committer can run arbitrary shell commands as the user who is running the svn commit hook (using back tics or$(evil_script.sh)).

I would suggest using pipe instead of double quotes when running checkin.php:

svnlook log -r $REV$REPOS) | \
/usr/bin/php -q /var/bugtracker/core/checkin.php

(I have not tested this).

Best regards,

Frans

Please remove the trailing parenthesis from the above fix:

svnlook log -r $REV$REPOS | \
/usr/bin/php -q /var/bugtracker/core/checkin.php

Sorry for noise.

Dear Sir,

Need help…
I have Mantis installed on 1 and 1 linux and SVN installed on Mac OSX,both are situated at different location. I want to integrate it. I scratched my head for a long time now.. need your help.. If you could help me in giving simpler steps.. that would be great help.. I have php …
Help
Regards
manish

[...] lot of information can be found on the net about integrating Subversion and Mantis when they both run on the same Linux server. Our situation is a bit different, being that [...]

Hi,

First of all, thanks all for the information (also the commenters). I’ve compiled all information and put it into another blog post, more specific to having SVN and Mantis on seperate servers.

Hi,

When I execute this command:

/path/to/php /path/to/mantis/core/checkin.php <<< "My web monkey fixed issue #1337 by accident."

It will show error message like these:

APPLICATION ERROR #400APPLICATION ERROR #400Database connection failed. Error received from database was #0: PHP Support for database is not enabled.Please use the “Back” button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

Would you tell me how to do this ?

Thank you very very much.

Best regards,
Tony.

[...] der Platte des Servers schlummerte — damit war das in fünf Minuten erledigt. Inspiriert von diesem Blog-Post, der das Verfahren mit SVN beschreibt, habe ich das ganze als [...]

[...] Integrating Mantis and Subversion [...]

Thanks a lot, I was able to add an hook to Subversion 1.6.3 installed on Windows Server 2003 with Mantis 1.2.0rc1.

With the help of this site (http://www.codeproject.com/KB/threads/redir.aspx) I was able to code my own post-commit.exe hook in C++.

Workaround for portuguese, spanish, french et. al. accented charecters.

I had to add the post-commit like this:
——————————————
#!/bin/bash
export LANG=”en_US.UTF-8″

REPOS=”$1″ REV=”$2″

auth=$(svnlook author -r$REV $REPOS) dt=$(svnlook date -r $REV$REPOS)
changed=$(svnlook changed -r$REV $REPOS) log=$(svnlook log -r $REV$REPOS)
n=$’\n’ /usr/bin/php -q /var/www/mantis/scripts/checkin.php <<< "Changes to /rail01/pmi/projects/neasden [rev${REV}] by $auth,$dt$n$log$n$changed"

—————————————-

otherwise tou get posts on mantis like this

ora c?\195?\161 est?\195?\161 o c?\195?\163o d'?\195?\161gua em ora?\195?\167?\195?\163o n?\195?\169?

The workaround is to add export LANG="en_US.UTF-8" to the post-commit script

my setup:
- debian 4.0 etch (all defaults for lamp)
- mantis-1.2.1
- svnserve

[...] and Mantis on Windows. I wanted to allow developers to resolve issues via commit comment. I read this great page about it, and used it as a starting point for Windows [...]

Hi how are you. I wanted to know that in my case on commit i need the issue to be set to feedback status and also to assign it to a different user. I have been able to change the status to feedback but I cant assign it to a different guy. please help

[...] Not so hard when you follow easy instructions like from this article on alt-tag.com: http://alt-tag.com/blog/archives/2006/11/integrating-mantis-and-subversion/ [...]

[...] a little Googling, I was able to turn up a few useful resources to help me get this set up. This article gave a nice overview of SVn hooks and Mantis integration, while this one provided a nice [...]

I would like to setup the build environment using Subversion+Mantis+Hudson on solaris.
Please shed a light on this.

[...] Integrating Mantis and Subversion [...]

[...] все Источник: http://alt-tag.com/blog/archives/2006/11/integrating-mantis-and-subversion/. Хотя нет. Не все. Если у вас возникли проблемы с [...]

[...] integración entre Mantis y Subversion se encuentra probada y registrada en varios sitios en el Internet, y de ser conseguida resulta de mucha ayuda para poner orden en el desarrollo. De forma sencilla, [...]

[...] #!/bin/sh REPOS="$1" REV="$2" SVNLOOK=/usr/local/bin/svnlook PHP=/usr/bin/php MANTIS=/srv/www/novo/html/mantis/core/checkin.php COMMIT_MSG=$SVNLOOK log -r$REV "$REPOS"$PHP -f $MANTIS <<zzzMantiszzz Revision:$REV: \$COMMIT_MSG zzzMantiszzz Also, great details at Alt Tag [...]

[...] This is my first post on my blog! As a first post, I thought I’d share how I have integrated my private SVN (Subversion) repository and my public Mantis bug tracker. You can automatically add comments to Mantis after you check-in files in your SVN repository, using a post-commit event. For more information, click here. [...]

Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a bit, but other than that, this is wonderful blog. An excellent read. I will definitely be back.

Thanks for the article. Works great! However, I’ve been struggling with the regexp. My typical Mantis note looks something like

————————-
SVN generated message (Repo: X, Rev: X)
User: USER_NAME
Issue ##
————————-

MESSAGE

The “formatting” is done via the batch script (dashes and newlines etc), but with this setup I can’t get the recognition to fix the issue when simply using e.g. ‘fixed’ in the message. If I write for instance MESSAGE = ‘fixed issue #13′ it works ok, but since I’m already mentioning the issue nr above the actual message I would need somewhat more clever regexp to interpret the issue nr first and then if the message contain e.g. fixed, fixes, fixing etc.

Hi,
I have an environment where the Mantis BT installation is on a linux server and the SVN installation is on a windows server.

Does anyone have a procedure I could refer?
Kind Regards,
Jason

[...] Subversion -> Mantis [...]