svn利用钩子post-commit自动更新到线上测试服务器(测试中未验证)
2016-05-05 00:49
525 查看
创建一个新的版本库:
再建一个工作副本:
配权限:
进入该目录后,checkout出一个副本,用于同步上线上服务器的路径:
配WEB:
我这里是开一个nginx vhost
http://darkyin.blog.51cto.com/6260426/1361132
[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
相关文章推荐
- sublime Text 3安装模板插件
- 对照Java学习Swift--下标(Subscripts)
- GC
- StackExchange.Redis 使用 - 事件(五)
- web开发 那些年基于Redis的Provider库
- cin与scanf cout与printf效率问题
- HDOJ(HDU) 2137 circumgyrate the string(此题用Java-AC不过!坑)
- HDOJ(HDU) 2137 circumgyrate the string(此题用Java-AC不过!坑)
- 新建一个Fragment时需要宿主Activity向该Fragment传递数据
- 编辑距离
- Minecraft源码分析(3) - 刷怪笼(MobSpawner)逻辑
- java实现输入指定年打印该年日历练习
- Header函数和PHP_AUTH_USER做用户验证
- 如果有人问你数据库的原理,叫他看这篇文章(下)
- CentOS7,使用tar命令解压缩文件
- 【Python】【辅助程序】练手小程序:记录外网动态IP地址
- Android性能优化相关
- 常用Linux及其对应的桌面
- SPOJ DETER3 (矩阵行列式)
- Tools 获取应用程序当前版本号 工具类