SVN under windows, linux realizes automatic update of WEB directory

http://www.bestphper.cn/article-132.html

 

Repository management is performed through SVN. After each submission, the latest uploaded version must be updated on the SVN server to the WEB directory for synchronization. The operation is cumbersome and the efficiency is low. Using SVN hook script for WEB directory synchronization can solve this problem very well. Since the test machine and the SVN library are in the same machine, it is more convenient to handle.

 

 

There is a hooks directory under the svn project, which stores all the templates of hook scripts

post-commit.tmpl is triggered after the client commit is submitted

Here's how to automatically update the repository under Windows and Linux:

Create a new post-commit.bat file in the hooks directory under the storage directory of the SVN project repository:

windows:

@echo off
SET REPOS=%1
SET REV=%2
SET DIR=%REPOS%/hooks
SET PATH=%PATH%;
SET WORKING=E:/www/o135
svn update %WORKING% --username o135 --password o135123

Note: The above method must add the bin in the SVN server installation directory to the path path (environment variable). SVN is installed through setup. By default, the bin directory will be added to the path path. If it is installed through a compressed package, it must be added manually.

To know if this script is wrong, you can enter in the cmd command line: C:\Documents and Settings\Administrator> e: /svn/hooks/post-commit.bat to test. The following message appears to indicate that the script was successfully executed:

C:\Documents and Settings\Administrator>e:/svn/hooks/post-commit.bat
is upgrading 'E:\www\o135':
version 15.

The red part is the location of the repository, and you can modify it according to the actual location.

In the future, regardless of the machine, this script will be triggered only through the svn commit command to automatically synchronize the web directory.

 

linux:

The principle under linux is the same as that of windows. Only the new file name is different.

Create a new post-commit file in the hooks directory under the storage directory of the SVN project repository:

vi post-commit

Add the following code:

#!/bin/sh
WEB=/home/data/o135
export LANG=en_US.UTF-8
svn update $WEB --username o135 --password 'o135123'

save, exit. .

Give permissions to this script:

chmod 777 post-commit

Test it to see if the script has permission issues

./post-commit

The script will run automatically every time the client submits an operation in the future.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326315142&siteId=291194637