The general approach is to use the Python web.py framework to write an updated script that updates the SVN in an HTTP manner.
Implementation method:
The following steps are implemented with the WEB.PY framework:
The code is as follows |
Copy Code |
1, framework installation cd/usr/local/soft/ wget http://webpy.org/static/web.py-0.33.tar.gz Tar zxvf web.py-0.33.tar.gz CD web.py-0.33 Python setup.py install 2, writing code vi/usr/local/webpy/subversion_web.py #!/usr/bin/env python # ... Import Web,os render = Web.template.render (' templates/') url = ( '/', ' Index ' ) app = Web.app Lication (URLs, Globals ()) Class index: def get (self): Text = Os.popen ("CD/HOME/HTDOCS/APP;SVN Update"). Read () Print text Return text If __name__ = = "__main__": App.run () 3, program always background execution nohup/usr/local/w ebpy/subversion_web.py Exit 4, test update http://192.168.1.36:8080/ Display as: C app/sitemap.xml Updated to revision 32786. |
In this step, it is no problem to manually update SVN to the development server. But the biggest problem is semi-automatic, programmers submit code to the SVN server, also need to open the browser, manually in the browser to perform http://192.168.1.36:8080/, before you can sync code to the development server. As time passes, it is troublesome.
Recently found SVN also hooks this function, very good, the theory of automatic synchronization has been achieved. Next is to think of a way, how the general batch execution http://192.168.1.36:8080/, the first of course is to think of curl, considering that the SVN service is in Windows, so to download a Windows version of the
Curl to the D disk directory, and then new in the Hooks directory
The code is as follows |
Copy Code |
Post-commit.bat @echo off D:/curl.exe-i http://192.168.1.36:8080/ |
Save Exit!
So each time the programmer submits the code to the SVN,SVN will automatically trigger the Post-commit.bat script, thus synchronizing updates! Simple and convenient, and suitable for different servers!