Managing repository management is always a hassle for network administrators, as it usually involves going into into the shell to create the repository itself.
Redmine solves this problem using reposman.rb, which can be run regularly by a cronjob and thus automate repository creation. But this is still inconvenient—you still need to wait for the repository to be created, and you can only manage one type of SCM at once. Thus, we are going to install and configure the Redmine SCM Creator plugin to manage repository creation for us.
This tutorial is oriented primarily towards setting up SVN repository creation, as git repository management is better done by the Redmine Git Hosting plugin (Setup Guide). For instructions on how to set up Redmine, visit this tutorial before continuing on.
Once again, this tutorial will assume that you are running all commands from the root user, unless otherwise noted. Do NOT use the root user as your primary account, it should be restricted to setup and administration only.
Step 1: Setting up the SVN repository location
We’ll start by creating the SVN repository hosting location at /var/svn, and setting it to the correct permissions:
$ mkdir /var/svn $ chown www-data:www-data /var/svn $ chmod 755 /var/svn
Step 2: Creating the Redmine SVN Creator Configuration File
Edit the file at /usr/share/redmine/config/scm.yml, and set its contents as follows:
$ cat /usr/share/redmine/config/scm.yml production: auto_create: false deny_delete: false 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/svn svnadmin: /usr/bin/svnadmin url: svn
For more information about the configuration options, visit this wiki page
Step 3: Installing the plugin
We’re now actually going to install this plugin into redmine:
$ cd /usr/share/redmine/ $ ./script/plugin install http://svn.s-andy.com/scm-creator $ rake db:migrate_plugins RAILS_ENV=production
Restart apache to see if this plugin installed properly:
$ service apache2 restart
Now, if you create a new project and go to the Project→Settings→Repositories tab, you should be able to select “Subversion” and create a repository.
Step 4: Setting up SVN with WebDAV, Apache, and Redmine authentication
Start by getting the required packages to configure SVN through Apache:
$ apt-get install libapache2-svn libapache-dbi-perl libapache2-mod-perl2 libdbd-mysql-perl libdigest-sha-perl libauthen-simple-ldap-perl
Enable SVN via WebDAV:
$ a2enmod dav $ a2enmod dav_svn $ a2enmod perl
Set up authentication
Link the the Redmine authentication module to Apache, so we can load it the configuration file.
$ ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm
Configure Apache to serve SVN in redmine.example.com/svn:
$ cat /etc/apache2/sites-available/redmine.example.com.conf PerlLoadModule Apache::Redmine <VirtualHost your-server-ip:80> SuexecUserGroup "#1012" "#1012" # fill these in from the automatically generated values in the config file ServerName redmine.example.com ErrorLog /var/log/virtualmin/redmine.example.com_error_log CustomLog /var/log/virtualmin/redmine.example.com_access_log combined DocumentRoot "/usr/share/redmine/public" PassengerResolveSymlinksInDocumentRoot on Options Indexes ExecCGI FollowSymLinks <Location /svn> DAV svn SVNParentPath "/var/svn" Order deny,allow Deny from all Satisfy any PerlAccessHandler Apache::Authn::Redmine::access_handler PerlAuthenHandler Apache::Authn::Redmine::authen_handler AuthType Basic AuthName redmine <Limit GET PROPFIND OPTIONS REPORT> Require valid-user Allow from server-ip-address Satisfy any </Limit> <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> RedmineDSN "DBI:mysql:database=redmine_default;host=localhost" RedmineDbUser "redmine" RedmineDbPass "redmine-db-password" </Location> </VirtualHost>
Replace redmine, redmine_default, and redmine-db-password with the appropriate values for your configuration.
Step 5: Add a cronjob to regularly update the repository listings
Redmine normally only checks for updates to the repository when you access the project ‘repository’ tab, which can be somewhat clumsy when you want to see the repository updates in closer to real time. Thus, we will setup a regular cronjob to fetch new updates every minute:
Enable WS for repository management
Go to Administration→Settings→Repositories, and check “Enable WS for repository management”, and generate a random API key for use later.
Edit the crontab with the following command:
$ crontab -e
and add the following line to the end:
* * * * * curl "http://redmine.example.com/sys/fetch_changesets?key=API-KEY" > /dev/null 2>&1
Make sure that you have curl installed with the following command:
$ apt-get install curl
Save the crontab, and you’re done with this step.
Restart Apache and have fun!
At this point, you have a working SVN repository creation and authentication system, synchronized with and controlled by Redmine. You should be able to check out the project repositories at http://redmine.example.com/svn/[project-identifier], and track the progress of the repository within Redmine.
If you would also like to put together a fully functional Git hosting solution, check out http://aeturnalus.com/software/redmine-git-hosting-setup-ubuntu-12-04-lts/
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.