Project

General

Profile

RedmineRepositories » History » Version 36

Etienne Massip, 2011-06-07 17:49
Added authentication notice

1 1 Jean-Philippe Lang
h1. Repositories
2
3 19 Mischa The Evil
{{>toc}}
4 1 Jean-Philippe Lang
5 19 Mischa The Evil
h2. General information
6 1 Jean-Philippe Lang
7 24 Alex Bevilacqua
Redmine natively supports integration with different SCM-tools: "Subversion":http://subversion.tigris.org/, "CVS":http://www.nongnu.org/cvs/, "Mercurial":http://www.selenic.com/mercurial/, "Darcs":http://darcs.net/, "Git":http://git-scm.com, and "Bazaar":http://bazaar-vcs.org/.
8 19 Mischa The Evil
9
Note that you need to install the appropriate binaries on your Redmine host and make sure that these binaries are available in the @PATH@ environment variable:
10
11 9 Jean-Philippe Lang
|*SCM*|*Tested with*|*Comments*|
12 17 Jean-Philippe Lang
|Subversion|1.3 & 1.4 & 1.5 & 1.6|1.3 or higher required|
13 9 Jean-Philippe Lang
|CVS|1.12.12|1.12 required, won't work with CVSNT|
14
|Mercurial|0.9.3| |
15 27 Fabio Leitao
|Bazaar|1.0.0.candidate.1 & 2.0.4| |
16 1 Jean-Philippe Lang
|Darcs|1.0.7||
17 16 Jean-Philippe Lang
|Git|1.5.4.2||
18 9 Jean-Philippe Lang
19 19 Mischa The Evil
For example, if you want to access Subversion repositories in Redmine, you'll have to install the svn binaries on the Redmine host. Redmine currently doesn't make use of the Ruby Bindings for Subversion.
20 1 Jean-Philippe Lang
21 35 Travis Briggs
Additionally, be sure to enable any SCM you wish to use globally: @Administration->Settings->Repositories->Enabled SCM@
22
23 1 Jean-Philippe Lang
h2. Attaching an existing repository to a project
24
25
In the project settings, make sure that the 'Repository' module is enabled and go to the 'Repository' tab.
26
Select the SCM that corresponds to your repository and enter the path or URL of your repository.
27
28
*Important*: When you first browse the repository, Redmine retrieves the description of all of the existing commits and stores them in the database.
29 34 Graham King
This is done only once per repository but can take a very long time (or even time out) if your repository has hundreds of commits.
30 1 Jean-Philippe Lang
31
To avoid this, you can do it offline.
32
After having your repository declared in Redmine, run the following command:
33 19 Mischa The Evil
<pre>
34
$ ruby script/runner "Repository.fetch_changesets" -e production
35
</pre>
36 1 Jean-Philippe Lang
37 34 Graham King
All commits will be retrieved in to the Redmine database.
38 1 Jean-Philippe Lang
39 36 Etienne Massip
Since Redmine 0.9.x, you can use a link to execute fetch_changesets for a specific project, or all.
40 28 Enderson Maia
41
http://redmine.example.com/sys/fetch_changesets (=> fetches changesets for all active projects)
42 30 Tao Lin
http://redmine.example.com/sys/fetch_changesets?id=foo (=> fetches changesets for project foo only)
43 1 Jean-Philippe Lang
44 36 Etienne Massip
If you want to make it an automatic task, don't forget to append authentication information via API @key=@ URL parameter as described in [[Rest_api#Authentication|Rest_api#Authentication]].
45 28 Enderson Maia
46 1 Jean-Philippe Lang
h3. Subversion repository
47
48 19 Mischa The Evil
The usual protocols are supported (eg. @http:@, @svn:@, @file:@), just enter the URL of the repository.
49 1 Jean-Philippe Lang
50 19 Mischa The Evil
For example:
51 1 Jean-Philippe Lang
<pre>
52
http://host/path/to/the/repository
53
</pre>
54
55 5 Jean-Philippe Lang
You can specify a username and password if the repository requires authentication.
56
57 1 Jean-Philippe Lang
Note: if you want to access the repository using @svn+ssh://@, you'll have to configure svn+ssh to be non-interactive.
58 34 Graham King
This requires you to setup a public/private key pair for ssh authentication.
59 1 Jean-Philippe Lang
60
h3. CVS repository
61
62
Enter:
63
* the URL of the repository (it can be either a path or a connection string, eg. @:pserver@).
64
* the module name
65 15 Azamat Hackimov
66 19 Mischa The Evil
For example:
67
<pre>
68
:pserver:login:password@host:/path/to/the/repository
69
</pre>
70 10 Thomas Lecavelier
71 19 Mischa The Evil
h3. Git repository
72 1 Jean-Philippe Lang
73 19 Mischa The Evil
h4. Local environment setup
74 10 Thomas Lecavelier
75 19 Mischa The Evil
Redmine requires a *bare* and *local* repository to enable browsing through Redmine.
76
77 21 Mischa The Evil
Imagine you want to browse the to-do list manager project "Donebox": its clone URL is @git://github.com/ook/donebox.git@.
78 19 Mischa The Evil
On the server where you're running Redmine, create a directory accessible by the user running your Redmine server:
79 10 Thomas Lecavelier
<pre>
80
$ sudo mkdir -p /var/redmine/git_repositories
81
$ sudo chown rails:rails /var/redmine/git_repositories
82
$ cd /var/redmine/git_repositories
83
</pre>
84
85 19 Mischa The Evil
Note the second line: it changes the ownership of the newly created directory to the user @rails@ and the group @rails@. Of course, you have to replace it according to your server settings (it can be @www-data@, @apache@ or when you are having a very bad sysadmin: @root@). Keep in mind that this user needs to have the (local-)permissions to run the @git@ command.
86 1 Jean-Philippe Lang
87 19 Mischa The Evil
h4. Create the bare repository
88
89
After the preceding steps have been taken it is time to create our bare repository:
90 1 Jean-Philippe Lang
<pre>
91
$ pwd
92
/var/redmine/git_repositories
93 29 Burt Culver
$ git clone --bare git://github.com/ook/donebox.git donebox.git
94
Initialized empty Git repository in /var/redmine/git_repositories/donebox.git/
95 1 Jean-Philippe Lang
remote: Counting objects: 401, done.
96
remote: Compressing objects: 100% (246/246), done.
97
remote: Total 401 (delta 134), reused 401 (delta 134)
98
Receiving objects: 100% (401/401), 179.55 KiB | 185 KiB/s, done.
99
Resolving deltas: 100% (134/134), done.
100 29 Burt Culver
$ cd donebox.git
101
$ git remote add origin git://github.com/ook/donebox.git
102 1 Jean-Philippe Lang
</pre>
103 10 Thomas Lecavelier
104 29 Burt Culver
Our bare repository is now created successfully! Now go to your Redmine project settings, go to the repositories tab and choose @git@ as the SCM, then put in the "Path to .git directory" (in our example this is @/var/redmine/git_repositories/donebox.git/@) and save the settings. Have a look at your repository tab: you should now be able to browse your repository successfully.
105 10 Thomas Lecavelier
106 29 Burt Culver
Note: of course, this git repository won't update by itself. You'll have to @git fetch@ it regulary by hand, set up a cron job which will execute the @git fetch@-command automatically for you or use a post-receive hook, like this one : 
107 25 Benoit Bénézech
108
<pre>
109
echo "Post receive-hook => updating Redmine repository"
110 31 Stephen McGinty
sudo -u my_redmine_user -p secret perl -we '`cd /redmine/repositories/my_repo.git && git fetch && git reset --soft refs/remotes/origin/master`'
111 1 Jean-Philippe Lang
</pre>
112 25 Benoit Bénézech
113 31 Stephen McGinty
Note the git reset, you'll *need it* to update the git tree and see your changes in the Repository view. The 'soft' option is required since it is a bare repository and the default option (mixed) will fail since there is no working tree.
114 29 Burt Culver
115
If you are using github, you can use the [[Plugin_List#Github-Hook-plugin|Github Hook Plugin]]
116 19 Mischa The Evil
117 22 Babar O'Cap
h4. Bare repository on Windows
118
119
If your bare repository is install on *Windows*, adding :
120
<pre>;%GIT_PATH%\cmd;%GIT_PATH%\bin;</pre> to your %%PATH%% environment variable.
121
Where %%GIT_PATH%% is the install directory of Git (eg: _C:/Git_)
122
123 33 Beau Simensen
h4. Setting up a mirror repository (shortcut, tracking branches)
124
125
The method above works fine under most circumstances but it can take a lot of tweaking to get certain things working if you have more than just a master branch. More information on the problem and the solution can be found on this "Stack Overflow question":http://stackoverflow.com/questions/4698649/how-do-i-get-a-remote-tracking-branch-to-stay-up-to-date-with-remote-origin-in-a.
126
127
This method will help to keep branches from the repository's origin updated and visible in Redmine's repository browser. This is really only relevant if the local copy of the repository is only being used as a read-only copy specifically for Redmine's use. For example, the project is hosted on GitHub but Redmine is being used for issue tracking.
128
129
<pre>
130
$ pwd
131
/var/redmine/git_repositories
132
$ git clone --mirror git://github.com/ook/donebox.git donebox.git
133
Initialized empty Git repository in /var/redmine/git_repositories/donebox.git/
134
remote: Counting objects: 717, done.
135
remote: Compressing objects: 100% (561/561), done.
136
remote: Total 717 (delta 320), reused 371 (delta 134)
137
Receiving objects: 100% (717/717), 211.35 KiB | 86 KiB/s, done.
138
Resolving deltas: 100% (320/320), done.
139
$ cd donebox.git
140
$ git branch
141
  WW
142
  asap
143
  bugcat
144
  comeback
145
* master
146
</pre>
147
148
This method relies on the @--mirror@ option available for the git clone command. This option may not be available to older versions of git. In that case, please reference the "Stack Overflow question":http://stackoverflow.com/questions/4698649/how-do-i-get-a-remote-tracking-branch-to-stay-up-to-date-with-remote-origin-in-a for some ideas on how to setup this type of mirror functionality without using the @--mirror@ option.
149
150
151 19 Mischa The Evil
h3. Mercurial repository
152
153 23 Yannick Warnier
To synchronize with a Mercurial repository, you will have to have a local clone of the repository on the same server you have Redmine installed on. Let's say you put Redmine in /var/www/redmine.example.com/www and have put your mercurial repository in /var/www/sources.example.com/repo/example, you would have to select *Mercurial* as a SCM, then enter */var/www/sources.example.com/repo/example* in the repository text box.
154
155
This will start checking out the Mercurial repository, and you won't see the results straight away. Wait for a few seconds (or possibly minutes), and click the *Repository* tab of your project (not of your configuration settings). You should now see the results appear.
156 19 Mischa The Evil
157
h3. Bazaar repository
158
159 26 David Muir
Put in the full path to your repository in "Root directory"
160
i.e. /home/username/bzr/repo/trunk
161
162
163
You'll need to make sure that bzr and bzrlib can be found in ENV['PATH'] and ENV['PYTHONPATH'] respectively.
164
ie. edit config/environment.rb and add:
165
166
<pre>
167
ENV['PYTHONPATH'] = '/path/to/pythonlib'
168
ENV['PATH'] = "#{ENV['PATH']}:/path/to/bzr/bin"
169
</pre>
170 19 Mischa The Evil
171 1 Jean-Philippe Lang
h3. Darcs repository
172 21 Mischa The Evil
173 32 Mischa The Evil
TODO
174 21 Mischa The Evil
175
h2. Repository user-mapping
176 19 Mischa The Evil
177 32 Mischa The Evil
TODO