Project

General

Profile

HowTo setup automatic refresh of repositories in Redmine on commit » History » Revision 6

Revision 5 (Etienne Massip, 2010-07-07 09:52) → Revision 6/29 (Jürgen Hörmann, 2010-07-14 04:45)

h1. HowTo setup automatic refresh of repositories in Redmine on commit 

 {{>toc}} 

 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. 

 Exemples: 

 * _/sys/fetch_changesets?key=<your service key>_ fetches changesets for all active projects 
 * _/sys/fetch_changesets?id=<project id>&key=<your service key>_ fetches changesets from the repository of a specific project 

 See #2925 for original feature request. 

 h2. Step 1 : configure Redmine to accept the request 

 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. 

 h2. Step 2 : setup a post-commit script on the SCM server 

 You have to setup a post-commit script which will call the previous URL. 

 h3. Subversion 

 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 : 

 <pre> 
 #!/bin/sh 

 curl "http://<redmine http://<redmine url>/sys/fetch_changesets?key=<your service key>" key> 
 </pre> 

 Or, on a Windows system (2 files) : 

 * post-commit.cmd : 
 <pre> 
 cscript "%~dp0refresh_redmine.vbs" //Nologo >> "%~dp0refresh_redmine.log" 2>&1 
 </pre> 

 * refresh_redmine.vbs : 
 <pre> 
 private const REDMINE_SERVICE_KEY = "<your service key>" 

 Call HTTPPost("http://<redmine url>/sys/fetch_changesets", "key=" & REDMINE_SERVICE_KEY) 

 Private Function HTTPPost(sUrl, sRequest) 
   set oHTTP = CreateObject("Microsoft.XMLHTTP") 
   oHTTP.open "POST", sUrl,false 
   oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 
   oHTTP.setRequestHeader "Content-Length", Len(sRequest) 
   oHTTP.send sRequest 
   HTTPPost = oHTTP.responseText 
 End Function 
 </pre>