HowTo setup automatic refresh of repositories in Redmine on commit » History » Version 11
razumuhin map, 2010-12-06 14:35
1 | 1 | Etienne Massip | h1. HowTo setup automatic refresh of repositories in Redmine on commit |
---|---|---|---|
2 | 4 | Mischa The Evil | |
3 | {{>toc}} |
||
4 | 1 | Etienne Massip | |
5 | 3 | Etienne Massip | Since of version 0.9.0, you can use an HTTP submission, either GET or POST, to automatically refresh Redmine after you committed your modification in your repository. |
6 | 1 | Etienne Massip | |
7 | 10 | Maxim Strukov | Examples: |
8 | 1 | Etienne Massip | |
9 | * _/sys/fetch_changesets?key=<your service key>_ fetches changesets for all active projects |
||
10 | 7 | Felix Schäfer | * _/sys/fetch_changesets?id=<project identifier>&key=<your service key>_ fetches changesets from the repository of a specific project |
11 | 1 | Etienne Massip | |
12 | See #2925 for original feature request. |
||
13 | |||
14 | h2. Step 1 : configure Redmine to accept the request |
||
15 | |||
16 | Web service for repositories must by activated in the Administration menu and the generated key will have to be used by the caller in Step 2. |
||
17 | |||
18 | h2. Step 2 : setup a post-commit script on the SCM server |
||
19 | |||
20 | You have to setup a post-commit script which will call the previous URL. |
||
21 | |||
22 | h3. Subversion |
||
23 | |||
24 | 8 | Etienne Massip | Simply add a @post-commit@ (or @post-commit.cmd@ on a Windows system) script file in the hooks sub-directory which contains the HTTP request call : |
25 | <pre><code class="sh"> |
||
26 | 1 | Etienne Massip | #!/bin/sh |
27 | |||
28 | 6 | Jürgen Hörmann | curl "http://<redmine url>/sys/fetch_changesets?key=<your service key>" |
29 | 8 | Etienne Massip | </code></pre> |
30 | 1 | Etienne Massip | |
31 | 11 | razumuhin map | or |
32 | wget http://your/redmine/paht/sys/fetch_changesets?key=<API KEY> |
||
33 | Note: Dont forget wget in your computer path. |
||
34 | |||
35 | 1 | Etienne Massip | Or, on a Windows system (2 files) : |
36 | |||
37 | 8 | Etienne Massip | * @post-commit.cmd@ : |
38 | <pre><code class="cmd"> |
||
39 | 2 | Etienne Massip | cscript "%~dp0refresh_redmine.vbs" //Nologo >> "%~dp0refresh_redmine.log" 2>&1 |
40 | 8 | Etienne Massip | </code></pre> |
41 | 1 | Etienne Massip | |
42 | 8 | Etienne Massip | * @refresh_redmine.vbs@ : |
43 | <pre><code class="vbs"> |
||
44 | 1 | Etienne Massip | private const REDMINE_SERVICE_KEY = "<your service key>" |
45 | |||
46 | Call HTTPPost("http://<redmine url>/sys/fetch_changesets", "key=" & REDMINE_SERVICE_KEY) |
||
47 | |||
48 | Private Function HTTPPost(sUrl, sRequest) |
||
49 | set oHTTP = CreateObject("Microsoft.XMLHTTP") |
||
50 | oHTTP.open "POST", sUrl,false |
||
51 | oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" |
||
52 | oHTTP.setRequestHeader "Content-Length", Len(sRequest) |
||
53 | oHTTP.send sRequest |
||
54 | HTTPPost = oHTTP.responseText |
||
55 | End Function |
||
56 | 8 | Etienne Massip | </code></pre> |
57 | 9 | András Veres-Szentkirályi | |
58 | h3. Git |
||
59 | |||
60 | Simply add a @post-receive@ (even on a Windows system, no extension is required) script file in the hooks sub-directory which contains the HTTP request call: |
||
61 | |||
62 | <pre><code class="sh"> |
||
63 | #!/bin/sh |
||
64 | |||
65 | curl "http://<redmine url>/sys/fetch_changesets?key=<your service key>" |
||
66 | </code></pre> |
||
67 | |||
68 | This setup works in the "usual" case, where Redmine's repository is set to a bare Git repository, so no commits can happen directly in there. If you have a rare setup with a non-bare repository linked to Redmine, you need to add the script as a @post-commit@ hook as well. |
||
69 | |||
70 | Don't forget to make the file(s) executable on UNIXish systems, more information about Git hooks can be found in the "githooks":http://www.kernel.org/pub/software/scm/git/docs/githooks.html man page. |