创建一个新的版本库:

[root@centos03 svn]# pwd
/home/svn
[root@centos03 svn]# svnadmin create webtest
[root@centos03 svn]# tree webtest/
webtest/
├── conf
│   ├── authz
│   ├── passwd
│   └── svnserve.conf
├── db
│   ├── current
│   ├── format
│   ├── fsfs.conf
│   ├── fs-type
│   ├── min-unpacked-rev
│   ├── rep-cache.db
│   ├── revprops
│   │   └── 0
│   │   └── 0
│   ├── revs
│   │   └── 0
│   │   └── 0
│   ├── transactions
│   ├── txn-current
│   ├── txn-current-lock
│   ├── txn-protorevs
│   ├── uuid
│   └── write-lock
├── format
├── hooks
│   ├── post-commit.tmpl
│   ├── post-lock.tmpl
│   ├── post-revprop-change.tmpl
│   ├── post-unlock.tmpl
│   ├── pre-commit.tmpl
│   ├── pre-lock.tmpl
│   ├── pre-revprop-change.tmpl
│   ├── pre-unlock.tmpl
│   └── start-commit.tmpl
├── locks
│   ├── db.lock
│   └── db-logs.lock
└── README.txt 10 directories, 28 files

再建一个工作副本:

[root@centos03 www]# pwd
/alidata/www
[root@centos03 www]# mkdir webtest
[root@centos03 www]# #授权:否则提交会报权限错误!
[root@centos03 www]# chmod -R 777 webtest/

配权限:

[root@centos03 conf]# vi svnserve.conf
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = read
auth-access = write
password-db = /home/svn/webtest/conf/passwd
authz-db = /home/svn/webtest/conf/authz
[root@centos03 conf]# vi passwd
[users]
# harry = harryssecret
# sally = sallyssecret
svnadmin = 123456
test = 123456
[root@centos03 webtest]# vi /home/svn/webtest/conf/authz
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = svnadmin
user = test
[/]
@admin = rw
[/webtest]
@admin = rw
* =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[root@centos03 webtest]# ps -ef |grep svn
root      2586     1  0 13:33 ?        00:00:00 svnserve -d -r /home/svn/webtest/
root      2590  2475  0 13:33 pts/0    00:00:00 grep svn

进入该目录后,checkout出一个副本,用于同步上线上服务器的路径:

[root@centos03 www]# svn co svn://192.168.1.72/webtest
svn: URL 'svn://192.168.1.72/webtest' doesn't exist
[root@centos03 www]# ls /home/svn/
test webtest #有两个版本库启动的时候应该是:svnserve -d -r /home/svn/
[root@centos03 www]# ps -ef|grep svn
root 2650 1 0 14:00 ? 00:00:00 svnserve -d -r /home/svn/
root 2678 2475 0 14:04 pts/0 00:00:00 grep svn
[root@centos03 www]# svn co svn://192.168.1.72/webtest
Checked out revision 0.
[root@centos03 www]# ls
phpwind sx webtest xxzz

配WEB:

我这里是开一个nginx vhost

[root@centos03 vhosts]# vi webtest.conf
server {
        listen       83;
        server_name  localhost;
        index index.html index.htm index.php;
        root /alidata/www/webtest;
        location ~ .*\.(php|php5)?$
        {
                #fastcgi_pass  unix:/tmp/php-cgi.sock;
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi.conf;
        }
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
                expires 30d;
        }
        location ~ .*\.(js|css)?$
        {
                expires 1h;
        }
       
        include /alidata/server/nginx/conf/rewrite/default.conf;
        access_log  /alidata/log/nginx/access/webtest.log;
}
[root@centos03 vhosts]# service nginx reload
Reloading nginx!
[root@centos03 hooks]# cp post-commit.tmpl post-commit
[root@centos03 hooks]# which svn
/usr/bin/svn
[root@centos03 hooks]# vi post-commit
[root@centos03 hooks]# pwd
/home/svn/webtest/hooks
REPOS="$1"
REV="$2"
SVN=/usr/bin/svn
WEB=/alidata/www/webtest
RSYNC=/usr/bin/rsync
LOG=/tmp/rsync_web.log
WEBIP=192.168.1.73
#这是线上web服务器IP
export LANG=en_US.UTF-8
$SVN update $WEB --username svnadmin --password 123456
if [ $? == 0 ]
echo "" >>$LOG
echo `date` >> $LOG
echo "#####################" >>$LOG
$RSYNC -vaztpH --timeout=90 --exclude-from=/home/svn/webtest/exclude.list $web root@$WEBIP:/www/>>$LOG
if
#--exclude-from 可不要根据需求不同步的排除

[root@centos03 hooks]# chmod +x post-commit

http://darkyin.blog.51cto.com/6260426/1361132

svn利用钩子post-commit自动更新到线上测试服务器(测试中未验证)的更多相关文章

  1. 分享下使用 svn,测试服务器代码自动更新、线上服务器代码手动更新的配置经验

    分享下使用 svn,测试服务器代码自动更新.线上服务器代码手动更新的配置经验 利用SVN的POST-COMMIT钩子自动部署代码 Linux SVN 命令详解 Linux SVN 命令详解2 使用sv ...

  2. 使用 SVN Hook 实现服务器端代码自动更新

    之前的做法是客户端提交代码之后,再去服务器端项目中 svn up 一下来更新代码,让服务器端的项目更新到最新版本.可以编写一个 post-commit 钩子脚本来实现服务器端代码的自动更新,它在 SV ...

  3. git 利用hook 实现服务器自动更新代码

    如何利用git的hook实现提交代码后自动更新? 因为个人开发经常需要提交代码,每次都需要连接服务器去pull代码,重启服务器就显得十分繁琐,因此github提供了一个时间钩子,用户push代码后可以 ...

  4. svn利用钩子脚本功能实现代码同步到web目录

    一.hook简单介绍 为了方便管理员控制提交的过程 ,Subversion提供了hook机制.当特定的 事件发生时,相应的 hook会被调用,hook其实就相当于特定事件的处理函数.每个hook会得到 ...

  5. svn利用钩子实现代码同步到web目录

    思路:  找 到SVN Server中的仓库(Repositories)文件夹的位置,在相应的项目文件夹中找到hooks文件夹.在该文件夹中添加一个post- commit文件:当有commit动作发 ...

  6. windows svn利用钩子实现代码同步到web目录

    思路:  找 到SVN Server中的仓库(Repositories)文件夹的位置,在相应的项目文件夹中找到hooks文件夹.在该文件夹中添加一个post- commit文件:当有commit动作发 ...

  7. python学习笔记(Tkinter编程利用Treeview实现表格自动更新)

    博主今天总结这段时间抽空写的一个GUI编程项目 功能是查看本地打印机队列,可选择指定队列重新打印 直接上图 UI设计包括3个区域左上方,右上方和下方列表区域 使用网格grid方法来分配位置 下面是界面 ...

  8. 不停机不更新代码线上调试BUG的工具

    如果你有以下痛点,请你查看本文章: 1.我改的代码为什么没有执行到?难道是我没 commit?分支搞错了? 2.遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗? 3.线上遇到某个用户的 ...

  9. SVN跨服务器自动更新--实现文件分发

    目标:SVN版本库提交,服务器中的工作拷贝能自动update. 实现方法:subversion, curl,php脚本实现,并且入mysql库来进行管理.改hosts文件来进行访问!提交触发钩子脚本时 ...

随机推荐

  1. WinForm中动态添加控件 出现事件混乱,解决办法记录。

    还是在抢票软件中出的问题,我没点击一个联系人,要生成一排控件,其中有席别combobox这样的下拉框控件,会出现如下图所示的问题:问题描述:在代码中动态创建的控件,事件混乱了,一个控件触发了所有同类型 ...

  2. UIScrollview自动布局,UIScrollviewAutolayoutDemo

    参考文档:http://www.cocoachina.com/ios/20150104/10810.html UIScrollviewAutolayoutDemo地址:http://pan.baidu ...

  3. 锋利的jQuery-2--判断jQuery获取到的对象是否存在$().length

    1.使用js获取不存在的对象: document.getElementById("tt").style.color = "red"; 如果网页中不存在id = ...

  4. Mongodb for C# 分组查询

    #region 排序获取集合 static List<BsonDocument> GetPagerWithGroup(string connectionString, string dat ...

  5. svn命令在linux下的使用

    svn命令在linux下的使用 SVN软件版本管理 三 12th, 2008 转载本站文章请注明,转载自:扶凯[[url]http://www.php-oa.com[/url]] 本文链接: [url ...

  6. JSON做下拉表格

    主页面,5-18j.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http ...

  7. DNS服务器配置

    导读 DNS(Domain Name Server,域名服务器)是进行域名(domain name)和与之相对应的IP地址 (IP address)转换的服务器.DNS中保存了一张域名(domain ...

  8. BNUOJ 1038 Flowers

    春天到了,师大的园丁们又开始忙碌起来了. 京师广场上有一块空地,边界围成了一个多边形,内部被划分成一格一格的.园丁们想在这个多边形内的每一格内种植一些花. 现在请你帮忙计算一下一共最多可以种多少花. ...

  9. STL库函数 持续更新

    *容器 (1)顺序容器 vector[顺序表直接访问] depue[前后直接访问] list[双向链表] vector 检索(用operator[ ])速度快 .push_back 在数组的最后添加一 ...

  10. FOJ 1075

    #include<stdio.h> #include<iostream> using namespace std; ]={,}; ]={}; void func() { ,fl ...