创建一个新的版本库:

[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. Advice for applying Machine Learning

    https://jmetzen.github.io/2015-01-29/ml_advice.html Advice for applying Machine Learning This post i ...

  2. ALTER 语句修改数据表

    1.修改数据表名:alter table 表名 rename 新表名; 2.修改列名: alter table 表名 change 列名 新列名(可以与旧的一样) 类型 默认值; 3.修改类型: al ...

  3. xss跨站攻击测试代码

    '><script>alert(document.cookie)</script> ='><script>alert(document.cookie)& ...

  4. UML用例图总结

    用例图主要用来描述“用户.需求.系统功能单元”之间的关系.它展示了一个外部用户能够观察到的系统功能模型图. [用途]:帮助开发团队以一种可视化的方式理解系统的功能需求. 用例图所包含的元素如下: 1. ...

  5. HTML5中的Range对象的研究

    一:Range对象的概念 Range对象代表页面上的一段连续区域,通过Range对象,可以获取或修改页面上的任何区域,可以通过如下创建一个空的Range对象,如下: var  range = docu ...

  6. sql 联合查询并更新

    update sales set sales.adminId = t.adminIdfrom (select a.adminId,a.realName from sales ,admin_admini ...

  7. WP8版微信5.4发布 新增夜间模式 暂没小视频

    经过近一个月的内测,WP8版的微信终于更新了v 5.4版本.新增聊天中的照片墙.识别图片二维码.夜间模式等功能,还对资源占用情况进行了优化,让程序可以更流畅的在低配置设备上运行. 不过,WP8版微信5 ...

  8. zstu.4019.排队购票(多维dp)

    排队购票 Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 1264  Solved: 808 Description 一常球赛开始前,售票工作正在进行中. ...

  9. Spring+Quartz实现定时任务的配置方法

    1.Scheduler的配置 <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" ...

  10. 5款Linux最佳照片管理软件

    在谈到 Linux 中的应用程序时,对于不同的用户.不同的使用场景以及不同的使用习惯,在同一类应用当中,总会有多种软件可供选择和备选.就 Linux 中的照片管理软件来说,相信此前的 Google P ...