Integrate Redmine and Subversion

1. Enable HTTPS for repository access

Redmine 0.8.5 on CentOS 5 fails to browse SVN repositories over SSL, it just prints "The entry or revision was not found in the repository". The reason is that security certificate must be manually approved unless SVN is run by root. To reproduce the problem, the SVN commands must be done as a normal user, because "root" is allowed to access the repository without seeing the certificate validation request.
First, login as root and edit /var/www/redmine/lib/redmine/scm/adapters/subversion_adapter.rb and change SVN_BIN = "svn" to SVN_BIN = "/usr/bin/svn --config-dir=/var/www/redmine/.subversion"
Create the new subversion environment for some non-root user

mkdir /var/www/redmine/.subversion
chown user.user /var/www/redmine/.subversion

Now login as your non-root user and access your repository. Any file/directory works and ‘log’ works just as well as check-out for our purposes.

svn --config-dir=/var/www/redmine/.subversion ls https://{path-to-svn-file}

Approve the certificate permanently. If you do not see a message make sure you are NOT "root". Make sure the certificate permission is NOT prompted for again. If it is make sure the user has write permission to the config-dir.
Now login as "root" again and allow http server to access and modify the subversion settings.

chown -R apache.apache /var/www/redmine/.subversion
/etc/init.d/httpd restart

2. Prefetch repositories

Open redmine setting page http://redmine.ourdom.com/settings/edit?tab=repositoriesand "Enable WS for repository management"
Create a project and attach http://localhost/svn/repo to it in the redmine web interface.
When you first browse the repository, Redmine retrieves the description of all of the existing commits and stores them in the database. This is done only once per repository but can very long (or even time out) if your repository has hundreds of commits. To avoid this, you can do it offline. After having your repository declared in Redmine, run the following command:

ruby /var/www/redmine/script/runner "Repository.fetch_changesets" -e production

All commits will be retrieved in the Redmine database.

2.0.1.  SOAP access without SSL

Problem: "reposman" does not work via SSL

<VirtualHost *:80>
ServerName redmine.ourdom.com:80
DocumentRoot /var/www/dummy
RewriteEngine on
SSLProxyEngine on
<Location /sys>
 Order allow,deny
 Allow from 127.0.0.1 192.168.1.4
</Location>
#RewriteCond %{REMOTE_ADDR} ^127\.0\.0\.1$ [OR]
#RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.4$ [OR]
RewriteRule ^/(sys/.+)$ https://redmine.ourdom.com/$1 [L,P]
#RewriteCond %{REMOTE_ADDR} .*
RewriteRule ^/(.*)$ https://redmine.ourdom.com/$1 [L,R]
</VirtualHost>

<VirtualHost *:443>
ServerName redmine.ourdom.com:443
DocumentRoot /var/www/redmine/public
RailsEnv production
<Location /sys>
 Order allow,deny
 Allow from 127.0.0.1 192.168.1.4
</Location>
</VirtualHost>

3. Manage SVN via WebService (reposman)

Run reposman to test redmine access to SVN repositories

cd /var/www/redmine/extra/svn
ruby reposman.rb --redmine-host=http://redmine.ourdom.com
     --svn-dir=/var/www/svn/repos --verbose       --owner=apache --url=http://svn.ourdom.com/svn/repos

If the command fails with

/usr/lib/ruby/1.8/rdoc/ri/ri_options.rb:53: uninitialized constant RI::Paths (NameError)

then edit reposman.rb and add "require 'rdoc/ri/ri_paths'" above all other require statements.
In case of success the output should look like this

- -> /sys/service.wsdl
- -> /sys/api

Add the following command to etc/cron.daily

#!/bin/sh
[ x"$1" = x"-v" ] || exec $0 -v > /var/log/reposman.log 2>&1
for repo in repos work ; do
  echo "=== $repo ==="
  /usr/bin/ruby /var/www/redmine/extra/svn/reposman.rb
                --svn-dir=/var/www/svn/$repo/ --url=https://svn.ourdom.com/svn/$repo/
                --redmine-host=http://track.ourdom.com --owner=apache --verbose
done

Комментарии

You can find it useful:
http://www.softjourn.com/redmine-svn

Отправить комментарий

Содержание этого поля является приватным и не предназначено к показу.
To prevent automated spam submissions leave this field empty.