SVN hooks +curl, real-time synchronization of the development server

Source: Internet
Author: User
Tags commit curl svn svn update

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.