Automatically updating Redmine from Rhodecode

For various reasons I'm switching my issue tracker from Mantis to Redmine. Redmine supports various Source Control Management systems (SCM), for Mercurial (my favourite one) they need access to a local copy of the repository, not an issue for me, but something to keep in mind.

Forward push to Redmine

After you activate the Mercurial in the general settings (/settings?tab=repositories), you need to activate the Fetch commits automatically and Enable WS for repository management
Then go to your Redmine project and open the settings\repositories page
Add a new repository and specify the details (note that you will need a local path.
Now for the Rhodecode side, we need a changegroup hook, you can add a local file on the server with the following contents (for Linux):
PROJECT="$(echo $PROJECT | tr '[A-Z]' '[a-z]')"
echo "Mercurial project: "$PROJECT
echo "Updating Changeset to Redmine Bug Tracker"
curl "http://REDMINESERVER/sys/fetch_changesets?key=$KEY&id=$PROJECT"&

Replace the REDMINESERVER with the actual webaddress of the Redmine server, and replace APIKEY with the key generated/shown by Redmine in the general settings page.

Make sure the local file is executable by the Rhodecode server user. Then switch to the Rhodecode Hooks page (/_admin/settings/hooks/edit), and add a changegroup.redmine hook and add the file location as the action:

Linking issues from commits

In the general Redmine Repositories settings page (/settings?tab=repositories) you can specify how Redmine should detect issue references from the commit message.
I have the following settings:
Be aware that Redmine expects a # in front of the issue number, so for referencing an issue you can use : ID #3. And for closing: fixes #45.

Now if you push your commit to Rhodecode, it will be forwarded to Redmine and linked to the correct issue, and show up in the tracker for that issue. If you want to track time used for the issue you can use the @ identifier followed by the amount of time use (see Redmine documentation)