Install SVN version management on Linux servers, automatically deploy code to projects

Source: Internet
Author: User
Tags svn update

Install SVN version management on Linux servers, automatically deploy code to projects

Http://bbs.aliyun.com/read/9715.html?spm=5176.7114037.1996646101.1.W3zw3X&pos=1

Http://v5sheji.com/archives/setupsvnonlinux.html

1. Install the SVN server side

Yum Install Subversion   

Download and install the SVN server side from the image

The middle will prompt whether OK, enter Y, confirm
Installation success prompt: ... complete!
Execute the following command in turn:

cd/usr/local/              //mkdir svnrepo                   //chmod777 Svnrepo            ///usr/local/svnrepo/first  //    CD First/conf               //

2. To modify the three configuration files under this directory

(1) svnserve.conf //Configure repository information and user file and user password file path, repository path

Anon-access = none       // defaults to readRead Write      // authentication with Write permission passwd      // account password profile authz-db = Authz         // permissions config file realm =            First //  Scope of entry into force             

(2) Authz //files, creating permissions for SVN Group and group users

[Group]   = DDL,SHL       //    [/]                   //@first = RW           //  First group user rights are read  /write * = R                 //

(3) passwd //Create or modify user passwords

[Users]   123456    // User name = password   123456    //

3. Then to set the self-start

Open the Self-boot file/etc/rc.local

#!/bin/sh*after*inif you don' do the Full Sys V style init stuff.   Touch

Add the following line

SVN command:

Lsof-i:3690    See if SVN starts   ps aux |  grep'svn'   finds all SVN-initiated processes   kill -9  2505     kills 2505 of this found SVN process   -d-r/usr/local/svnrepo/first start svn (you can put this to/etc/local/ rc.local file, enable start-up)

netstat -anp|grep svnserveCheck out the SVN information

SVN repository starting mode, now Svnrepo has first, test two repository

1: Single-version library starter svnserve-d-r/usr/local/svnrepo/first
2: Multi-version Library starter svnserve-d-r/usr/local/svnrepo
The difference is the start of the SVN command in the startup parameter-r specified directory.

4. Restrict different users ' permissions to different repository operations

Modify the Authz file in the Conf directory in the Repository
To configure the first repository as an example:

Authz

[groups]   = User1,user2  [First:/]             //= RW     //   * = r           //

passwd setting the user's account number and password in the group

[Users]  user1  123456  123456

5. Client Access

Assume that the client uses TORTOISESVN
Open the Repository browser to enter the address, svn://your SVN server ip:3690
Enter the user name DDL password 12345
Because there is no net repository in the file so you need to use the client right-click "Create Forder", and then "Add Forder"

6. Using Post-commit for automatic deployment

The SVN build is not just to store the code in the repository, but to deploy it synchronously to the corresponding project.

svn 目录的 /hooksThere's a bunch of tmpl in there, these tmpl can do a lot of things, but today we're going to talk about automatic deployment post-commit.tmpl .

Tmpl file is a template file, we want to use Post-commit to manually copy the contents of the corresponding Tmpl inside the new post-commit inside

CP Post-commit.tmpl Post-commit
STEP.1:

Then open the file empty content and modify it to the following code:

#!/bin/shexport LANG=zh_cn. utf-8/usr/bin/svn Update--username * * * * *--password/var/www/test

The first line means: Use SH to parse the script, because the syntax of the various shells is slightly different.

The second line is the encoding format: I'm using UTF-8 here.

The last line /usr/bin/svn is the svn path , not the project path, should be the same, the second sentence is the user name , password , and project path . --usernameThis comparison pit, online search out a lot of wrong, the front is actually two minus, English input method under.

STEP.2:

Modify executable permissions for Post-commit

chmod 755 Post-commit

STEP.3:

The server enters the project directory /var/www/test checkout the entire project.

Note Do not checkout folders here, the correct code should be this:

SVN checkout svn://{Your server address}:{port number}/test.    // Note There's a point behind the catalog.

At this point, if you follow this step down, there should be no problem, you can local commit code, automatically synced to the project.

6. Common mistakes that I have encountered

    1. 255 Error:Post-commit does not give execution permission or the head is not executed with SH, that is, no#!/bin/sh
    2. Tip Skip Directory: server directory does not have checkout code, remember must first checkout once, in order to synchronize
    3. There is no hint: This happens when the tool commits, but it is not synchronized, it is recommended that you go to Linux and use ./post-commit manual execution to read what is wrong. If garbled, please modify the in-file encoding format to GBK
    4. Tip * * * * is a direcitory: /usr/bin/svn You got this wrong, he's not a directory, it's SVN's path.

Install SVN version management on Linux servers, automatically deploy code to projects

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.