About SVN hooks

Source: Internet
Author: User
Tags svn update rsync

SVN hooks

A hook script is the way the shell is written, and a hook is a program that is triggered by some repository events.

Common hooks:

Post-commit: Executes the hook after the commit has completed successful creation. (Submission has been completed and cannot be changed)

After the update, by mail, notification

UPDATE triggers the checkout program, and then pushes it to the server

Pre-commit: Triggers execution of the script before the commit is completed.

Limit the size and extension of uploaded files, and control the submission of information to be entered

Here is a small example:

Rsync combined with SVN hooks for real-time data synchronization to the server

1. Create a synchronization web directory

Mkdir/data/www

2. Checkout the contents of SVN into the web directory

SVN Co svn://ip/sadoc/data/www--username=syk--password=syk123

3. Setting hooks

CP Post-commit.tmpl Post-commit

4. Writing scripts

1), > Post-commit

2), chmod post-commit

3), Vim Post-commit add:

#!/bin/bash

Repos= "$"

rev= "$"

Export Lang=en_us. UTF-8

Logpath= "/tmp/log"

[!-D ${logpath}] && mkdir ${logpath}-P

Svn=/usr/bin/svn

$SVN update--username SYK--password syk123/data/www

If [$?-eq 0]

Then

/usr/bin/rsync-az--delete/data/www/tmp/

Fi

5. Testing

Then we create a new file on SVN and submit it, and in the TMP directory we can see the new file.




This article is from the "Linux" blog, so be sure to keep this source http://syklinux.blog.51cto.com/9631548/1792475

About SVN hooks

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.