Automatically sync updates to Web site directory after SVN submits files in Linux

Source: Internet
Author: User
Tags commit svn svn update

Here to introduce you to the Linux in the SVN submitted files automatically synchronized updates to the Site Directory I hope this article will help you.

Sometimes it can be cumbersome to upload to a server for multiple files, but if you use the SVN hook script it is easy to implement the local SVN submission, automatically synchronize the code files to the remote server's Web site directory without having to upload them manually.

First, checkout code in the site directory, such as my directory is/data/www/test

SVN Co https://127.0.0.1/test/trunk//data/www/test/


Note that this is because sometimes I will directly modify the code on the server, so with checkout, if not required, you can use export, this instruction does not take. SVN version of the file.
After moving out of the code, you need to create a hook script, my version library is placed under/data/svn/test/, create a new Post-commit script, add the following:

#!/bin/sh
Repos= "$"
rev= "$"

Export LANG=ZH_CN. UTF-8 #字符集, consistent with the server, can perform locale command view
SVN update/data/www/test/#更新svn
Echo ' Date ', ' WhoAmI ', $REPOS, $REV >>/data/svn/test/hooks/svn_hook.log # record time log
Chown-r Web:web/data/www/test # Change the site directory file to the owner if you are using the root user update
Give Script execution command: chmod +x/data/svn/test/hooks/post-commit
This completes the SVN commit Automatic Update synchronization code.

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.