0
点赞
收藏
分享

微信扫一扫

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

就是耍帅 2022-03-11 阅读 104
svncentosphp


创建一个新的版本库:

[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
root      2590  2475  0 13:33 pts/0    00:00:00 grep svn
[root@centos03 conf]# vi svnserve.conf<br>[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<br>[root@centos03 conf]# vi passwd <br>[users]<br># harry = harryssecret<br># sally = sallyssecret<br>svnadmin = 123456<br>test = 123456<br>[root@centos03 webtest]# vi /home/svn/webtest/conf/authz <br>[groups]<br># harry_and_sally = harry,sally<br># harry_sally_and_joe = harry,sally,&joe<br>admin = svnadmin<br>user = test<br>[/]<br>@admin = rw<br>[/webtest]<br>@admin = rw<br>* =<br># [repository:/baz/fuz]<br># @harry_and_sally = rw<br># * = r<br>
[root@centos03 webtest]# ps -ef |grep svn<br>root      2586     1  0 13:33 ?        00:00:00 svnserve -d -r /home/svn/webtest/<br>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
[root@centos03 vhosts]# vi webtest.conf<br>server {<br>        listen       83;<br>        server_name  localhost;<br>        index index.html index.htm index.php;<br>        root /alidata/www/webtest;<br>        location ~ .*\.(php|php5)?$<br>        {<br>                #fastcgi_pass  unix:/tmp/php-cgi.sock;<br>                fastcgi_pass  127.0.0.1:9000;<br>                fastcgi_index index.php;<br>                include fastcgi.conf;<br>        }<br>        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$<br>        {<br>                expires 30d;<br>        }<br>        location ~ .*\.(js|css)?$<br>        {<br>                expires 1h;<br>        }<br>        <br>        include /alidata/server/nginx/conf/rewrite/default.conf;<br>        access_log  /alidata/log/nginx/access/webtest.log;<br>}<br>


[root@centos03 vhosts]# service nginx reload
Reloading nginx!



[root@centos03 hooks]# cp post-commit.tmpl post-commit<br>[root@centos03 hooks]# which svn<br>/usr/bin/svn<br><br>
[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

​​

​​

​​

 网名:bass 分享技术 突破难点 创新思维


举报

相关推荐

0 条评论