2012-04-24

I’m a big fan of both Redmine, the project management web application and Git, the distributed version control system.

Recently, I learned that it’s possible to integrate Git into Redmine so that git repositories for a project can be created via the Redmine web interface. This is done using plugins which connect Redmine with git hosting software: either gitosis or more recently, gitolite.

Unfortunately, this is a deeply-confusing process for novices like myself. There are multiple forks of the plugins, long threads in the Redmine forums that discuss various hacks/tweaks to make things work and no one authoritative source of documentation. After much experimentation, this is what worked for me. I can’t guarantee success for you.

My setup

I manage a work server which is a virtual machine running an old version of Ubuntu:

Redmine version is 1.3.1.stable.8917.

1. Install gitolite

On my machine, the system user gitolite was created automatically.

2. Create keys for gitolite user and run gl-setup

This is the important part. Ignore everything in the gitolite documentation about creating public keys on a client machine and copying them to the server. All that you want to do is create a public/private key pair on the server for the gitolite user.

3. Copy the gitolite user keys so as the webserver user can read them

My Redmine installation is in /var/www/rails/redmine-1.3, where I have read/write permissions as a normal user. If you don’t, use sudo where required. The webserver user is www-data on my system; some sources of documentation call this user redmine.

4. Install the redmine_git_hosting plugin

Assuming that you are still in the Redmine root directory:

Next, edit vendor/plugins/redmine_git_hosting/init.rb as described in the plugin documentation. However, note that you may have to edit the settings again later through the Redmine interface.

Finally, run the migration:

5. Edit sudoers file

Run visudo and add these lines:

6. Restart and configure Redmine

We’re almost there. Restart Redmine:

Navigate to Administration->Plugins->Redmine Git Hosting Plugin->Configure and double-check the server settings and git user (gitolite).

7. Add keys, projects and repositories

In Redmine you should now be able to:

Navigate to My Account

Add a public key (copy/paste) and give it a name

Create a project (or use an existing project)

Select Git as the option under project->Settings->Repository and save

Click Repository in the project menu and follow the instructions

A git-push from your local repository to the server should complete without error (or asking for a password). On the server, after the first push, you should see the repository in /var/lib/gitolite/repositories and your public key should be written to /var/lib/gitolite/.ssh/authorized_keys.

Remember: just ignore everything in the gitolite documentation about cloning the gitolite-admin repo to a client or adding public keys from a client. The idea here is that everything happens through Redmine, by giving the webserver user (www-data) privileges to add users, keys and repositories.

Filed under: computing, linux, rails, research diary Tagged: gitolite, how to, redmine, repository, ubuntu, version control

Show more