SVN可以通过svn或者http协议来进行svn co操作下拉代码,后者需要配置apache等成功设定才可,这篇文章通过在Subversion Edge中创建仓库,然后在客户端进行co和ci操作进行功能的说明。
可以参看如下内容进行目前最新版的5.2.4的Subversion Edge的环境准备。
环境说明:本文使用环境为在Virtual Box上创建的CentOS 7.6,IP为192.168.163.121,与主机进行端口映射,比如3343,主机通过localhost的3343直接可以访问csvn的Web服务。80端口的服务被映射为9999
使用如下信息进行登录
项目 | 详细 |
---|---|
登录URL | http://localhost:3343/csvn |
用户名 | admin |
用户密码 | admin |
点击Repository菜单进行进一步操作
点击Create按钮进行仓库的创建
输入仓库的名称,此处选择标准方式,会缺省创建trunk/branches/tags,这是svn和git在分支操作上明显的不同之处。
点击Create即可看到已经成功创建了名为demo-repo的svn仓库了。
然后点击左侧菜单栏中Repository list的链接,可以看到包含svn co访问地址的如下详细信息
修改hostname为所在机器的IP并保存,缺省会通过80端口进行http协议服务的访问。
执行命令:yum install svn -y
[root@liumiaocn ~]# yum install svn -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
...省略
Complete!
[root@liumiaocn ~]#
确认客户端版本信息
svn, version 1.7.14 (r1542130)
compiled Apr 11 2018, 02:40:28
Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository access (RA) modules are available:
* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
- handles 'http' scheme
- handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
[root@liumiaocn ~]#
实施co操作
[root@liumiaocn ~]# svn co http://localhost/svn/demo-repo demo-repo --username=admin
svn: warning: cannot set LC_CTYPE locale
svn: warning: environment variable LC_CTYPE is UTF-8
svn: warning: please check that your locale name is correct
Authentication realm: CollabNet Subversion Repository
Password for 'admin':
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
CollabNet Subversion Repository
can only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible. See the documentation for details.
You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
A demo-repo/tags
A demo-repo/trunk
A demo-repo/branches
Checked out revision 1.
[root@liumiaocn ~]#
liumiaocn:edge liumiao$ svn --version
svn, version 1.10.4 (r1850624)
compiled Nov 15 2019, 03:54:33 on x86_64-apple-darwin18.0.0
Copyright (C) 2019 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository access (RA) modules are available:
* ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
- using serf 1.3.9 (compiled with 1.3.9)
- handles 'http' scheme
- handles 'https' scheme
The following authentication credential caches are available:
* Plaintext cache in /Users/liumiao/.subversion
* GPG-Agent
* Mac OS X Keychain
liumiaocn:edge liumiao$
进行svn co操作
liumiaocn:edge liumiao$ svn co http://127.0.0.1:9999/svn/demo-repo demo-repo --username=admin
Authentication realm: CollabNet Subversion Repository
Password for 'admin': *****
A demo-repo/tags
A demo-repo/trunk
A demo-repo/branches
Checked out revision 1.
liumiaocn:edge liumiao$
在其中一个客户端上进行svn的ci操作
liumiaocn:edge liumiao$ ls
demo-repo
liumiaocn:edge liumiao$ cd demo-repo/
liumiaocn:demo-repo liumiao$ ls
branches tags trunk
liumiaocn:demo-repo liumiao$ cd trunk/
liumiaocn:trunk liumiao$ echo "Created in MacOS" >ReadME.md
liumiaocn:trunk liumiao$ svn add ReadME.md
A ReadME.md
liumiaocn:trunk liumiao$ svn commit -m "commit in MacOS SVN client"
Adding ReadME.md
Transmitting file data .done
Committing transaction...
Committed revision 2.
liumiaocn:trunk liumiao$ svn log
------------------------------------------------------------------------
r1 | svn | 2020-08-24 05:07:31 +0800 (Mon, 24 Aug 2020) | 1 line
Creating_initial_branch_structure
------------------------------------------------------------------------
liumiaocn:trunk liumiao$
更新并确认版本
liumiaocn:trunk liumiao$ svn update
Updating '.':
At revision 2.
liumiaocn:trunk liumiao$ svn log
------------------------------------------------------------------------
r2 | admin | 2020-08-24 05:42:42 +0800 (Mon, 24 Aug 2020) | 1 line
commit in MacOS SVN client
------------------------------------------------------------------------
r1 | svn | 2020-08-24 05:07:31 +0800 (Mon, 24 Aug 2020) | 1 line
Creating_initial_branch_structure
------------------------------------------------------------------------
liumiaocn:trunk liumiao$
[root@liumiaocn ~]# cd demo-repo/
[root@liumiaocn demo-repo]# ls
branches tags trunk
[root@liumiaocn demo-repo]# svn log
------------------------------------------------------------------------
r1 | svn | 2020-08-24 05:07:31 +0800 (Mon, 24 Aug 2020) | 1 line
Creating_initial_branch_structure
------------------------------------------------------------------------
[root@liumiaocn demo-repo]#
更新并确认版本
[root@liumiaocn demo-repo]# svn update
Updating '.':
A trunk/ReadME.md
Updated to revision 2.
[root@liumiaocn demo-repo]# svn log
------------------------------------------------------------------------
r2 | admin | 2020-08-24 05:42:42 +0800 (Mon, 24 Aug 2020) | 1 line
commit in MacOS SVN client
------------------------------------------------------------------------
r1 | svn | 2020-08-24 05:07:31 +0800 (Mon, 24 Aug 2020) | 1 line
Creating_initial_branch_structure
------------------------------------------------------------------------
[root@liumiaocn demo-repo]#
可以通过http协议进行访问,通过浏览器可以进行查看,登录时输入相应具有权限的用户名和密码,此处输入admin/admin
可以看到创建的trunk/branches/tags
进入trunk,可以看到刚刚提交的文件信息
liumiaocn:edge liumiao$ svn co http://127.0.0.1:9999/svn/demo-repo demo-repo --username=admin
svn: E170013: Unable to connect to a repository at URL 'http://127.0.0.1:9999/svn/demo-repo'
svn: E000054: Error running context: Connection reset by peer
liumiaocn:edge liumiao$
[root@liumiaocn ~]# firewall-cmd --list-ports
3343/tcp
[root@liumiaocn ~]#
[root@liumiaocn ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[root@liumiaocn ~]# firewall-cmd --reload
success
[root@liumiaocn ~]# firewall-cmd --list-ports
3343/tcp 80/tcp
[root@liumiaocn ~]#