Development
Tools

Install Redmine with automated git integration (Centos, Redhat)

I had a few days work on this one while it was supposed to be done in a hour. The problem? Lack of good documentation. There seems to be no complete tutorial on the Internet how to completely integrate git with Redmine so I figured to make one myself for you my dear reader but also a little bit for myself so I can easily find it back.

Good to know: I might have used yum but we all know that the repo’s of centos en redhad are way behind in version. Please make sure you have extra repo’s. I used:
epelwebtatic

Make sure you also use repo’s for a more updated ruby and gems. I’m going to start with the ruby install right from the bat. Please make sure your server has Apache and Mysql installed. This tutorial won’t explain that part.

Installing Ruby

Redmine works on ruby so we will start with installing ruby. You can install ruby in 2 ways.

From the source

Trough yum

Thoose the one you prefer I will use the yum method:

yum install ruby ruby-devel ruby-libs ruby-irb ruby-rdoc ruby-mysql

Just make sure that you have the right version of ruby. The standard repositories don’t have the later versions yet so make sure to use other repositories. I used version 1.8.5. Just make sure that you use a compatible version. You can see that here: Redmine Ruby Versions

Set the right permissions for the files

Test Run redmine

ruby script/server webrick -p 3000 -e production

People note this is only for testrunning redmine. Don’t use it for production. Use one of the many other guides in the Redmine wiki to setup redmine to use either passenger (aka mod_rails) or mongrel to serve up your redmine.

Installing and automating Git

Now we will start automating all git processes with Redmine. This means when you make a new project it will automatically create a repository for it. Since there are already many tutorials how to do this with svn ours will be about git.

First create a directory where all git repositories will be in. Mine is located at: “/home/redmine/git_repositories”

Maybe you already noticed. That this is completely different from the configuration the Redmine sites gives. This is because we will be using git’s git-smart-http protocol. With this you can push your repository straight to the http link. If you are a valid user. For this to work you need to make sure you git version is higher than 1.6.6. Also check all paths for this httpd config since some could be off. Just try to locate the correct files with “find / -name yourfilenamehere”.

You will need to patch your Redmine.pm to support. this protocol. You can find the patch for Redmine.pm here: Redmine.pm Patch Note:please make sure this patch isn’t already committed else you might patch a already fixed file. Also use linux “patch” to patch the file.

If everything is working correctly you should be able to push to the httpd “IF” your repository exists and is setup the right way.

Setting up Auto creation and checking

Some people might want Redmine to auto create their repository when a new project is added and keep tracking the changes. For this you will need to add 2 lines to the cron: