SVN uses the Hook scripting feature to synchronize code to the Web directory

Source: Internet
Author: User
Tags svn client svn update

First, Hook simple introduction

to facilitate administrator control over the submission process, Subversion provides a hook mechanism. When a particular event occurs, the corresponding hook is called, and the hook is actually the equivalent of a particular event's handler function. Each hook will have parameters associated with the event it handles, and depending on the return value of the hook, subversion will decide whether to continue the current commit process

to actually install an available hook, you need to install some executable program or script with the same name as the hook (such as Start-commit or Post-commit) in the Repos/hooks directory.


Second, the local machine svn automatic update

1. Export Mode (Backup)

When using an SVN client, it may be necessary to make a local backup of a version, such as a compressed package for publishing, to extract the contents from the SVN folder, to remove the hidden SVN configuration files such as. svn. The stupidest way to copy one out, then show the hidden files and delete all the. SVN folders. In the SVN menu, you can find the Export command, which can cleanly export the contents of the current SVN directory to the specified directory

For example, the SVN access address of your repository is Http://10.30.11.12:8080/svn/project1, you want to publish the/trunk/web folder under this repository to Tomcat, and the folder address to be published to Tomcat is d:/ TOMCAT/OPT/WEB,SVN Administrator username is ABC, password is 12345, then this hook program should be:
SVN export http://10.30.11.12:8080/svn/project1/trunk/web d:/tomcat/opt/web--force--username ABC--password 12345-- No-auth-cache


Note:
--force is said to force overwrite d:/tomcat/opt/web This folder, avoid this folder is not empty times wrong
--username ABC--password 12345 automatically transmits the user name and password as parameters
--no-auth-cache is saying that the user name and password are not cached for security reasons


2.update mode

Modify Hooks/post-commit

Export Lang=en_us. UTF-8
Svn=/usr/bin/svn

Static_dir=/web/root/wwwdeng #注意权限问题
$SVN update $STATIC _dir--username Deng--password 123456-- No-auth-cache

#必须加上 --no-auth-cache or it will be an error !

The default shell type is sh, which is best changed to Bash,sh is a subset of bash, and the CentOS sh is actually a soft link to bash

650) this.width=650; "title=" Untitled.png "alt=" wkiom1vjzkace3praaftxyiwirs242.jpg "src=" http://s3.51cto.com/ Wyfs02/m00/6d/6a/wkiom1vjzkace3praaftxyiwirs242.jpg "/>


3.update and export comparison

Update generates a hidden. SVN folder, which we do not need, of course, if the entire content of the publication, it is recommended to use update instead of export, because update only changes the changed parts, and export will re-export all content, network consumption is larger than update.


Third, SVN realization remote machine Automatic Update

the first realization of a machine through SSH without password login b machine, Modify the Post-commit file for a machine

/usr/bin/ssh-l root 192.168.127.183 "/bin/bash/home/www/svnup.sh"

Then create the svnup.sh executable file in the/home/www/directory of the B machine

vim/home/www/svnup.sh

/USR/BIN/SVN Update/web/root/code

The Post-commit script is automatically executed when the repository submits a request, and the Post-commit script automatically updates SVN with the remote machine execution shell script via ssh.



Note:

@echo off is not a DOS program,
But in DOS batches.
The dos of that year, all operations are done with keyboard commands,
When you have to enter the same command every time,
You can save so many commands as a batch,
From then on, just run this batch,
is equivalent to a few lines, dozens of lines of command.

DOS when running batch processing,
Each command in the batch is executed sequentially,
And will be displayed on the monitor,
If you don't want them to show,
You can add an "echo off"

Of course, "echo off" is also an order,
It will also show itself,
If not even this one shows,
Just put a "@" in front.

Having said so much,
I think it's very detailed,
Maybe you still don't understand.
Without a man of the age of DOS,
The idea is different from ours.

This article is from the "Nothing-skywalker" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1655385

SVN uses the Hook scripting feature to synchronize code to the Web directory

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.