Thursday 3 November 2016

How to configure Redmine for advanced integration with Subversion

How to configure Redmine for advanced integration with Subversion

Before starting this guide, take into account that this is not necessary to see the repository changes in the Redmine application. If you only want to see the repository changes and link to the issues, it is only necessary to configure the project repository: Project -> Settings -> Repository -> URL and Control Version System.

This Redmine configuration is for automatic repository creation and rights management. Since 1.1.3-1 version, Redmine Stack ships all required modules for this configuration. Notice that if you are using Virtual Appliances or AMIs the installdir variable is "/opt/bitnami". It could be necessary to use the "sudo" command if the Stack was installed by the root user.

This guide has been updated to work with Redmine 3+.

    Add the following lines in Apache configuration file (httpd.conf):

~~~
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule perl_module modules/mod_perl.so
~~~

Copy the Redmine.pm file into the Perl modules folder:

$ cp /installdir/apps/redmine/htdocs/extra/svn/Redmine.pm installdir/perl/lib/site_perl/5.8.8/*/Apache2/

Create a folder for the repository, for instance:

$ mkdir /installdir/repository
$ mkdir /installdir/repository/svn
$ chown root:daemon installdir/repository/ [or "your_user:your_user" if you installed the Stack without root privileges]
$ chown root:daemon installdir/repository/svn/ [or "your_user:your_user" if you installed the Stack without root privileges]
$ chmod 0755 /installdir/repository
$ chmod 0750 /installdir/repository/svn


Add to the @installdir/apps/redmine/conf/httpd-app.conf@ file.

`PerlLoadModule Apache2::Redmine
<Location /svn>
  DAV svn
  SVNParentPath "/installdir/repository/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 SVN Repository" 

  #read-only access   
  <Limit GET PROPFIND OPTIONS REPORT>
     Require valid-user 
     Allow from localhost
     Allow from 192.168.1.9
     Satisfy any
  </Limit>
  # write access
  <LimitExcept GET PROPFIND OPTIONS REPORT>
    Require valid-user
  </LimitExcept>

  ## for mysql
  RedmineDSN "DBI:mysql:database=bitnami_redmine;host=localhost;mysql_socket=/installdir/mysql/tmp/mysql.sock" 

  RedmineDbUser "bitnami" 
  RedmineDbPass "bitnami_database_password"    
  #You can find this value at /installdir/apps/redmine/htdocs/config/database.yml
</Location>`


Restart the servers:

$ /installdir/ctlscript.sh restart

    Log in the Redmine application as Administrator and go to "Settings" -> "Repositories" -> "Enable WS for repository management".
    Click on "Generate a key" and save it.
    Add the following line in the crontab. You can edit the crontab using the command "crontab -e"

*/2 * * * * /installdir/ruby/bin/ruby /installdir/apps/redmine/htdocs/extra/svn/reposman.rb --redmine localhost:YOUR_APACHE_PORT/redmine --svn-dir /installdir/repository/svn --owner root --group daemon --command="/installdir/subversion/bin/svnadmin create --pre-1.6-compatible --fs-type fsfs" --url http://YOUR_PUBLIC_IP_ADDRESS:YOUR_APACHE_PORT/svn --key="YOUR_API_KEY" --verbose >> /var/log/reposman.log 


    If you have configured Redmine to accress through SSL, you can specify "--redmine @http://127.0.0.1:3001/redmine@" in the previous crontab line.
    You can check that everything works properly creating a project from the Redmine application and checking the /var/log/reposman.log file.

Permission and ownership setting

create folders for svn repository

*<installdir>/repository*
*<installdir>/repository/svn*

cd *<installdir>/repository/svn*

svnadmin create <repodirname>


From *<installdir>*

chown -R nobody:apache repository/
chmod -R 777 repository/svn/


2 comments:

  1. I have tried to type these codes twice, and I still have some problems. It doesn't work at all. Did anybody also have such a problem?

    ReplyDelete
  2. Your site is truly cool and this is an extraordinary moving article. 留学生辅导

    ReplyDelete