Redmine Git Hosting is a plugin for Redmine authored by Eric Bishop, further extended by John Kubiatowicz, which integrates the Git SCM system into Redmine’s project management system. At the end of this guide, you will have a server which can, from the Redmine GUI,
- Create git repositories for projects
- Serve git repositories via SSH, GIT, and HTTP(S)
- Add users to git repositories
This guide is a continuation of the one here, which shows how to install and configure Redmine in Ubuntu with Virtualmin.
Step 1: Get Gitolite
Gitolite is in the Ubuntu repositories, so just apt-get it.
$ apt-get install gitolite
Step 2: Configure Gitolite
The gitolite package needs to be reconfigured in order for it to finish setup.
In order for the gitolite setup to work properly, we need to generate a key for the gitolite user before we actually set it up.
$ cd /tmp $ ssh-keygen -t rsa -f /tmp/id_rsa
Do not give it a passphrase
$ dpkg-reconfigure gitolite
Use the default username and path, and give it /tmp/id_rsa.pub for the “Administrator’s SSH Key”
Copy the RSA keys into the gitolite user’s .ssh folder for safekeeping:
$ cp /tmp/id_rsa* /var/lib/gitolite/.ssh $ chown gitolite:gitolite /var/lib/gitolite/.ssh/* $ chmod 600 /var/lib/gitolite/.ssh/id_rsa $ chmod 644 /var/lib/gitolite/.ssh/id_rsa.pub
Step 3: Configure redmine’s SSH keys
Copy the RSA keys into a place where redmine can handle them:
$ mkdir /usr/share/redmine/.ssh $ cp /var/lib/gitolite/.ssh/id_rsa* /usr/share/redmine/.ssh/ $ cd /usr/share/redmine/ $ mv .ssh/id_rsa .ssh/gitolite_admin_id_rsa $ mv .ssh/id_rsa.pub .ssh/gitolite_admin_id_rsa.pub $ chown www-data:www-data -R .ssh $ chmod 700 .ssh $ chmod 600 .ssh/gitolite_admin_id_rsa $ chmod 644 .ssh/gitolite_admin_id_rsa.pub
Step 4: Install the redmine_git_hosting plugin
Install the plugin
$ cd /usr/share/redmine $ mkdir public/plugin_assets $ chown -R www-data:www-data public/plugin_assets $ chmod -R 777 public/plugin_assets $ gem install lockfile net-ssh rdoc inifile $ ./script/plugin install https://github.com/kubitron/redmine_git_hosting.git
Edit the init file at /usr/share/redmine/vendor/plugins/redmine_git_hosting/init.rb
Change ‘httpServer’ to ‘redmine.example.com’
Change ‘gitServer’ to ‘redmine.example.com’
Change ‘gitUser’ to ‘gitolite’
Migrate the databases
$ rake db:migrate_plugins RAILS_ENV=production
Link the plugin assets files
$ cd /usr/share/redmine/public/plugin_assets $ ln -s ../../vendor/plugins/redmine_git_hosting/assets ./redmine_git_hosting
Step 5: Add www-data to the sudoers file
Add these lines:
www-data ALL=(gitolite) NOPASSWD:ALL gitolite ALL=(www-data) NOPASSWD:ALL
Step 6: Restart Apache
$ service apache2 restart
Step 7: Configure redmine settings
Log in to redmine and navigate to Administration→Plugins→Redmine Git Hosting Plugin→Configure
Set Automatically Initialize Git Repositories if you want to automatically create a new git repository when you create a project. This conflicts with using redmine for other types of repositories, though, so use it with caution.
Yay, you’re done! You have a fully working project management system, which can integrate with git and provide you with a git repository accessible through read-only git://, SSH, and Smart HTTP. For SSH, public-key authentication is used: you can upload your public key as part of your redmine user profile. For those less inclined to use SSH (for whatever reason), Smart HTTP is also configured by default, and can be logged in with your Redmine user credentials.
If you have any issues, make sure that you restart apache (and with it, Rails):
$ service apache2 restart
before debugging—this has resolved many a configuration issue. Note that unless you have set up a proper SSL certificate, git will refuse to clone from your repository over HTTPS (it gives a TLS error), so just enable Smart HTTP hosting on both HTTP and HTTPS in the Project→Settings→Repositories section.
If you would also like to put together a fully functional SVN hosting solution, check out http://aeturnalus.com/software/svn-repository-management-redmine-ubuntu-12-04/
Note that you will have to resolve conflicts between the two plugins as per http://aeturnalus.com/software/hacking-scm-creator-redmine-git-hosting-cooperate/, but it’s a fairly simple fix.