SVN server hooks hooks can be used for multi-project auto-synchronization

Source: Internet
Author: User

Nonsense not much to say, directly on the Post-commit script:

The logs are all recorded, including synchronized files.

Vim Post-commit

#!/bin/shRepos= "$"#the path to the warehouserev= "$"#newly submitted version numberExport Lc_all= "ZH_CN." UTF-8 "Expor LANG= "en_US." UTF-8 "LOGFILE=/var/Log/svn-hooks.Log    #The log of the hook script#standard output and standard error output of the script are printed in the log fileexec1>> "$LOGFILE"exec2>&1SVN=/usr/bin/Svnsvnuser=luoxiaoguangsvnpwd=Lxg888webroot=/usr/local/nginx/Htmlsvnlook=/usr/bin/Svnlook Time=$(Date"+%y-%m-%d%h:%m:%s") AUTHOR=$($SVNLOOKAuthor-r$REV"$REPOS")#Submit Authorchangeddirs=$ ($SVNLOOKDirs-changed$REPOS)#Modified Catalog Collectionmessage=$ ($SVNLOOK Log-R$REV"$REPOS")#comment Information on submission, not recommended in ChinesefunctionMyecho () {Echo"$TIME" "$*"}myecho"**************************************************************"Myecho"Submit version:$REV $AUTHOR"Myecho"Submit notes:$MESSAGE"Myecho"Modify Directory: $ (echo$CHANGEDDIRS| Tr ' \ n ') "Masterdir=$(Echo"$CHANGEDDIRS" | HEAD-1)#the home directory in the Changeddirs#traverse the submitted code directory and synchronize to the Web server while[ "$CHANGEDDIRS" != "" ]; DoPROJECT=$(Echo $MASTERDIR| Awk-f/' {print $} ') Myecho"Current project:$PROJECT"#Judging the project folder    if[ "$PROJECT"= =" Ipengbei "];then WEB=/usr/local/nginx/html/Ipengbei Myecho MyechoProject$PROJECTSynchronization directory:$MASTERDIR"MyechoThe Sync$MASTERDIRTo TYQ:$WEBROOT/ipengbei "$SVN--non-interactive Update$WEB--username Luoxiaoguang--Password lxg888chmod-R 755$WEBElif ["$PROJECT"= =" Ipengbeiweb "];then WEB=/usr/local/nginx/html/ipengbeiweb Myecho MyechoProject$PROJECTSynchronization directory:$MASTERDIR"MyechoThe Sync$MASTERDIRTo Ipbweb_dev:$WEBROOT/ipengbeiweb "$SVNUpdate--non-interactive$WEB--username Luoxiaoguang--Password lxg888chmod-R 755$WEB        chmod-R 777$WEB/app/Runtimechmod-R 777$WEB/Webconfigchmod-R 777$WEB/UFElse:fi#Delete the synchronized directories in the directory collectionchangeddirs=$ (Echo"$CHANGEDDIRS" | Grep-v "^$MASTERDIR")    #Get new home directories that need to be synchronizedmasterdir=$ (Echo"$CHANGEDDIRS" | Head-1) Done

SVN server hooks hooks can be used for multi-project auto-synchronization

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.