SVN post-commit Hook Implementation code uploaded to the web directory

Source: Internet
Author: User
Tags commit datetime svn svn update

Description

Recently in the window with a virtual machine installed an Ubuntu system, set up the PHP environment, in order to easily view the code under the window, so want to build an SVN, directly to the corresponding web directory code, and then use the SVN hook,

SVN directory:/HOME/SVN

Station Directory:/var/www/html

Realize

1. Find the hooks directory of the SVN project, this is/home/svn/hooks. The default in the directory will be several corresponding actions of the hook template, we need to create a post-commit file

2. New Post-commit, content as follows

#!/bin/sh

Repos= "$"
rev= "$"
Datetime= ' Date +%f '
Datetimeminute= ' Date +%h%m%s '
SVN=/USR/BIN/SVN # You SVN's absolute path <span style= "color: #ff0000;" > This path can be found with the which SVN command </span>
Web=/var/www/html/helloyii #检出的web站点根目录 Helloyii as the project directory
Log=/tmp/svnhooks_${datetime}.log
$SVN Update $WEB--username username--password password--no-auth-cache #username你的用户名 password your password

3. Modify Post-commit Permissions

# Chmod-r 777 Post-commit

4.Checkout a code to the Web server

# cd/home/www/html
# sudo svn checkout svn://127.0.0.1/helloyii

5. Test
Test, I am here to modify the version library locally, point to commit, and then look at the Web (nginx) server data is updated to test.

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.