HowTo Automate repository creation » History » Version 1
Nicolas Chuche, 2007-11-18 20:13
1 | 1 | Nicolas Chuche | h1. Automating repository creation |
---|---|---|---|
2 | |||
3 | {{>TOC}} |
||
4 | |||
5 | h2. overview |
||
6 | |||
7 | As of version 0.5.0, Redmine is able to handle Subversion repository creation. This is done by reposman.rb a script found in extra/svn/. |
||
8 | |||
9 | Projects are retrieved from Redmine using a SOAP web service. This web service is disabled by default in Redmine. To enable it, go to « Administration -> Settings » and check *Enable WS for repository management*. |
||
10 | |||
11 | With a recent version of Redmine (0.6.0 or re. 860 and later), reposman.rb can register the new repository in Redmine for you and set the owner of repository to who you want. If you have an older version, you will have to register repositories by yourself. |
||
12 | |||
13 | Notice that reposman.rb before re 916 has a right problem. You don't need to update redmine, just "reposman.rb":http://redmine.rubyforge.org/svn/trunk/extra/svn/reposman.rb |
||
14 | |||
15 | h2. command line arguments |
||
16 | |||
17 | It takes 2 mandatory arguments: |
||
18 | |||
19 | * @svn-dir@: path to the directory where your svn repositories are located |
||
20 | * @redmine-host@: host name of your Redmine install |
||
21 | |||
22 | And two optional arguments (added in re. 860): |
||
23 | |||
24 | * @owner@: the files owner |
||
25 | * @url@: the base url Redmine will use to access your |
||
26 | repositories. With this option, reposman will register the new |
||
27 | repositories so that you will have nothing to do |
||
28 | |||
29 | The Perl reposman version is deprecated for new installation as it can't register and set the owner. |
||
30 | |||
31 | h2. question you should answer before going further |
||
32 | |||
33 | If Redmine and your svn repositories are on the same server, you can use the file:/// protocol of svn to browse them, but even if it seems a good idea, if later you want to move repositories on another server, you will have a problem because you can't change repository path in redmine for now. |
||
34 | |||
35 | The best way I can think of now is to do as if repositories and redmine are already on two different servers and using network subversion to allow Redmine browsing. |
||
36 | |||
37 | h2. automating repository creation to authenticate with apache/webdav and mod_perl |
||
38 | |||
39 | You need a reposman.rb re. 916 or later. If you have an older one, you just need to update "reposman.rb":http://redmine.rubyforge.org/svn/trunk/extra/svn/reposman.rb not Redmine. |
||
40 | |||
41 | You just need to invoke resposman.rb with the righ options : |
||
42 | |||
43 | <pre> |
||
44 | reposman.rb --redmine my.redmine.host --svn-dir /var/svn --owner www-data --url http://svn.server/svn-private/ |
||
45 | </pre> |
||
46 | |||
47 | FIXME go to ... |
||
48 | |||
49 | h2. testing and debugging |
||
50 | |||
51 | You can launch the script by hand with the @--verbose@ option with a user *that can't write* in the repository directory, you should have something like this : |
||
52 | |||
53 | <pre> |
||
54 | ruby reposman.rb --redmine my.redmine.host --svn-dir /var/svn --owner www-data --url http://svn.my.domain/svn/ --verbose |
||
55 | querying Redmine for projects... |
||
56 | retrieved 2 projects |
||
57 | treating project myproject |
||
58 | svnadmin: Repository creation failed |
||
59 | ... |
||
60 | </pre> |
||
61 | |||
62 | It's normal the creation failed, you have no right, but the good point is that reposman find the Web Service and projects. |
||
63 | |||
64 | If this doesn't work, make sure you have check the *Enable WS for repository management* option. |
||
65 | |||
66 | You can now add it in your crontab : |
||
67 | |||
68 | <pre> |
||
69 | cat /etc/cron.d/redmine |
||
70 | 10 * * * * root ruby reposman.rb --redmine my.redmine.host --svn-dir /var/svn --owner www-data --url http://svn.my.domain/svn/ >> /var/log/reposman.log |
||
71 | </pre> |
||
72 | |||
73 | h2. Web Service and Security |
||
74 | |||
75 | For the moment, the WS is open to everybody once actived and you surely don't want that someone register repository's project for you. You can block access to the WS with apache (if you don't use apache, I let you do your homework...) with the Location apache directive like this : |
||
76 | |||
77 | <pre> |
||
78 | <Location /sys> |
||
79 | Order allow,deny |
||
80 | Allow from ip.of.my.svn.server |
||
81 | </Location> |
||
82 | </pre> |
||
83 | |||
84 | So if you are using apache and mongrel, you will have something like that : |
||
85 | |||
86 | <pre> |
||
87 | <VirtualHost *:80> |
||
88 | ServerName redmine.my.domain |
||
89 | ServerAdmin webmaster@localhost |
||
90 | |||
91 | <Location /sys> |
||
92 | Order allow,deny |
||
93 | Allow from ip.of.my.svn.server |
||
94 | </Location> |
||
95 | |||
96 | ProxyPass / http://localhost:3000/ |
||
97 | ProxyPassReverse / http://localhost:3000/ |
||
98 | </VirtualHost> |
||
99 | </pre> |