Integrate Subversion with Mantis

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

Follow these steps:

  • [Configure Subversion access over HTTP](/installer/apps/subversion/get-started/configure-use-svn-repository/.

  • Create a repository using the following commands:

      $ sudo mkdir installdir/repositories
      $ sudo svnadmin create installdir/repositories/myapp
      $ sudo chown -R daemon:bitnami installdir/repositories
  • Create a new Mantis user, which will be the user that the script will run as. Edit the installdir/apps/mantis/htdocs/config_inc.php file and add the following lines:

      /* Subversion Connection*/
      $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';
  • Create the post-commit script, which will call Mantis after every commit, at installdir/repositories/mantis/hooks/post-commit. Fill it with this content:

      auth=$($SVNLOOK author -r $REV $REPOS)
      dt=$($SVNLOOK date -r $REV $REPOS)
      changed=$($SVNLOOK changed -r $REV $REPOS)
      log=$($SVNLOOK log -r $REV $REPOS)
      installdir/php/bin/php -q installdir/apps/mantis/htdocs/scripts/checkin.php <<< "Changeset [${REV}] by $auth, $dt$n$log$n$changed"
  • Change script permissions so that it can be executed by the daemon user:

      $ sudo chown daemon:bitnami installdir/repositories/mantis/hooks/post-commit
      $ sudo chmod u+x installdir/repositories/mantis/hooks/post-commit

This script will add a line to the corresponding Mantis issue number when a commit message references that issue number, such as:

$ svn commit -m "whatever issue #number whatever"

It will also close the Mantis issue with status “resolved” when a commit message includes the word “fixed” and the issue number, like this:

$ svn commit -m "whatever fixed issue #number whatever"
Last modification April 8, 2020