Installing Redmine SCM Repository Creation plugin¶
This plugin is an alternative for Redmine reposman.rb
tool1. It actually does the same - helps in creating and registering Subversion/Git/Mercurial/Bazaar repositories. Unlike reposman.rb
the plugin can work only with local repositories (ones which can be accessed with file://
protocol for SVN and with just path for Git/Mercurial/Bazaar).
Assuming you already have installed Subversion, Git, Mercurial and/or Bazaar and the Apache DAV module. Please refer to your operating system manual on how to do this if not.
Creating root directory¶
First you need to choose where repositories are going to be stored and to create this directory. For example, for SVN I chose /var/lib/svn
.
# mkdir /var/lib/svn
This directory should be writtable by the user Redmine is ran from (this can be www-data
, apache
or nobody
- depending on the OS2).
Change the owner and the group:
# chown www-data:www-data /var/lib/svn
If you are not sure about the owner try running the following command:
# ps aux | grep ruby www-data 32262 4.3 12.1 262304 127864 ? S 14:39 15:55 ruby /usr/share/redmine/public/dispatch.fcgi
Also make sure the directory can be written by the user:
# ls -l /var/lib | grep svn drwxr-xr-x 18 www-data www-data 4096 May 17 12:44 svn
To change permissions do:
# chmod 0755 /var/lib/svn
Do the same for Git, Mercurial and/or Bazaar.
Configuring the plugin¶
The plugin reads its configuration from #{RAILS_ROOT}/config/scm.yml
.
Copy sample scm.yml
file from the plugin directory to #{RAILS_ROOT}/config/
and modify it:
production:
auto_create: false
deny_delete: true
pre_create: /usr/local/bin/pre-create.sh
post_create: /usr/local/bin/post-create.sh
pre_delete: /usr/local/bin/pre-delete.sh
post_delete: /usr/local/bin/post-delete.sh
svn:
path: /var/lib/svn
svnadmin: /usr/bin/svnadmin
url: svn
git:
path: /var/lib/git
git: /usr/bin/git
options: --bare
url: http://git.myhost.com
update_server_info: true
git_ext: true
append: .git
mercurial:
path: /var/lib/mercurial
hg: /usr/bin/hg
bazaar:
path: /var/lib/bazaar
bzr: /usr/bin/bzr
init: init-repository
log_encoding: UTF-8
append: trunk
For more information about the configuration options check this Wiki page.
Automatic creation¶
You can configure the plugin to create a repository automatically when a project is registered. For this change the auto_create
option to true
or force
(for meanings of these values check this page). When the automatic creation is enabled the project registration form will have an additional field:
Installing plugin¶
To install the plugin do:
- Install Ruby Octokit
If you plan to create Github repositories or register hooks there. - Copy
redmine_scm
directory to#{RAILS_ROOT}/plugins
- Run:
rake redmine:plugins:migrate RAILS_ENV=production
- Restart Redmne
Configuring Apache/DAV¶
It is recommended to configure your SVN/Git/Mercurial server to use usernames, passwords and permissions from the Redmine database.
Refer the following links on what to do next:- For Subversion:
- For Git (it is slightly more complicated):
- For Mercurial (did not test it):
Note: For Redmine based SVN/Git/Mercurial authentication to work the repository name and the project identifier must be identical.
Troubleshooting¶
Repository is not removed¶
SCM Creator uses the FileUtils.remove_entry_secure function when removing a repository to avoid local security vulnerability. Quotes from Ruby-Doc:
WARNING: You must ensure that ALL parent directories cannot be moved by other untrusted users. For example, parent directories should not be owned by untrusted users, and should not be world writable except when the sticky bit set.
WARNING: Only the owner of the removing directory tree, or Unix super user (root) should invoke this method. Otherwise this method does not work.
See also this page.
See also¶
- http://www.redmine.org/projects/redmine/wiki/HowTo_configure_Redmine_for_advanced_Subversion_integration
- http://www.redmine.org/projects/redmine/wiki/Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl
- http://www.redmine.org/projects/redmine/wiki/HowTo_configure_Redmine_for_advanced_git_integration
- http://www.redmine.org/projects/redmine/wiki/HowTo_configure_Redmine_for_advanced_Mercurial_integration
- http://www.ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure
1 but you can use both
2 this page describes installation under Unix-like OSes only