Redmine Refresh Repository API Plugin

A simple Redmine plugin that exposes repository refresh calls.

By default, Redmine does not automatically refresh commits from the repository. This means things like the Activity screen or feeds get out of date if you don’t use the Repository browser often.

This can be fixed by adding a script that uses Rails’ script/runner to invoke Redmine commands to a Cron job or, if your set-up allows, to a post-commit hook. However, the former means the server running Redmine is continuously polling your SCM server, while the latter is much more elegant yet requires your SCM server to be the same as the one running Redmine. In some situations, these solutions just don’t cut it. This plugin is designed to enable a remote (SCM) server to trigger repository refreshes in Redmine via HTTP.

Installing this plugin adds the following routes to your Redmine installation:

http://your.redmine-installation.org/repositories/refresh/project-identifier

http://your.redmine-installation.org/repositories/refresh/project-identifier.xml

GETting or POSTing to these will trigger Redmine to fetch the latest commits from the given repository.

You can download it for free from the refresh_repository_api_plugin repository on GitHub, or install it directly from your Redmine installation.

Usage

Put the `refresh_repository_api’ directory inside the vendor/plugins directory of your Redmine installation and restart the server.
The most elegant way to do this, is to use Rails’ plugin script. Inside your Redmine installation directory, perform:

script/plugin install git://github.com/micheljansen/refresh_repository_api_plugin.git

And restart the server.

Create a post-commit hook in your SCM. How exactly this works depends on your SCM, but it usually boils down to creating a shell script containing the actions to perform. For a Subversion repository, it suffices to put:

#!/bin/sh
curl http://your.redmine-installation.org/repositories/refresh/project-identifier.xml?key=YOUR_KEY_HERE

as an executable file called “post-commit” inside the hooks directory of your repository database.

The API relies on Redmine’s RSS keys to work. For a logged-in user, these can be found in any of the “Also available in: Atom” links throughout the Redmine User Interface. If, for instance, the link at the bottom of the Repository screen says:
http://your.redmine-installation.org/repositories/revisions/project-identifier?format=atom&key=1uzti1m64oeXn28FI2nORxFOfUeGApHzKE6Ii4cf
then 1uzti1m64oeXn28FI2nORxFOfUeGApHzKE6Ii4cf is your key and you should put it instead of YOUR_KEY_HERE.

It is safest to create a new user for this, but you can also use an existing account. Whichever you choose, make sure the user has rights to “Refresh changesets”. This can be found in the “Roles and permissions” administration screen.