VisualSVN Server设置同步服务

做web开发为了随时能了解和看到和测试程序发布后的效果,之前是开发的时候多数情况下是svn提交完后,再FTP提交,麻烦费事,就想着将SVN提交后自动将数据同步到测试目录下,然后随时让团队其他人看到效果。

查看了一下svn的命令,写了一个post-commit钩子脚本,发现不行,然后搜了下其他人的,多数都是这么写钩子:

@echo off
“C:\visualSVN\VisualSVN Server\bin\svn.exe” update “D:\webHost” –username svn –password 000000

但实际运行的时候发现是不行的,必须要将svn设置为非安全链接http,才可以,否则始终会提示类似

svn: E175002: OPTIONS of ‘https://xxxxxxx: Server certificate verification failed: issuer is not trusted (https://xxxxx)

这样的错误提示,在这之前还有其他类似的错误,但基本属于权限问题,一般将visualsvn的启动用户设置一下权限就可以了。

这个错误始终搞不定,看过有人说是通过缓存什么的(http://my.oschina.net/bufenye/blog/58264)(3楼),但实际做起来还是不行,后来考虑svn应该有类似的命令能解决这样的问题的,

使用:svn help update 会输出关于update命令的参数帮助:

Valid options:
  -r [--revision] ARG      : ARG (some commands also take ARG1:ARG2 range)
                             A revision argument can be one of:
                                NUMBER       revision number
                                '{' DATE '}' revision at start of the date
                                'HEAD'       latest in repository
                                'BASE'       base rev of item's working copy
                                'COMMITTED'  last commit at or before BASE
                                'PREV'       revision just before COMMITTED
  -N [--non-recursive]     : obsolete; try --depth=files or --depth=immediates
  --depth ARG              : limit operation by depth ARG ('empty', 'files',
                             'immediates', or 'infinity')
  --set-depth ARG          : set new working copy depth to ARG ('exclude',
                             'empty', 'files', 'immediates', or 'infinity')
  -q [--quiet]             : print nothing, or only summary information
  --diff3-cmd ARG          : use ARG as merge command
  --force                  : force operation to run
  --ignore-externals       : ignore externals definitions
  --changelist [--cl] ARG  : operate only on members of changelist ARG
  --editor-cmd ARG         : use ARG as external editor
  --accept ARG             : specify automatic conflict resolution action
                             ('postpone', 'working', 'base', 'mine-conflict',
                             'theirs-conflict', 'mine-full', 'theirs-full',
                             'edit', 'launch')
                             (shorthand: 'p', 'mc', 'tc', 'mf', 'tf', 'e', 'l')
  --parents                : make intermediate directories

Global options:
  --username ARG           : specify a username ARG
  --password ARG           : specify a password ARG
  --no-auth-cache          : do not cache authentication tokens
  --non-interactive        : do no interactive prompting
  --trust-server-cert      : accept SSL server certificates from unknown
                             certificate authorities without prompting (but only

                             with '--non-interactive')
  --config-dir ARG         : read user configuration files from directory ARG
  --config-option ARG      : set user configuration option in the format:
                                 FILE:SECTION:OPTION=[VALUE]
                             For example:
                                 servers:global:http-library=serf

看到上面的蓝色三个参数,豁然开朗,果断加入,终于可行了^_^

有个小插曲,挺尴尬的,在网上搜索来的那句钩子,我直接给复制了,只该了路径,结果显示出现什么“文件、卷标错误”之类的,后来才看到是引号用的全角(因为编辑器里看双引号全角和半角不是很明显的区别),再后来是出现类似

svn: E170001: OPTIONS of ‘https://xxxxxx’: authorization failed: Could not authenticate to server: rejected Basic challenge (https://xxxxxx)

应该是帐号无法访问的缘故,可明明是正确的帐号密码的,开始想着可能是密码包含特殊字符的缘故,改了,还不行,再后来才发现那个–username svn –password 000000看着好奇怪,哈哈,是“-”写成了“–”。改过来,成功!事实证明,无脑的单纯复制会造成多么大的困扰,哈哈。以后还是自己敲键盘吧。

总结上面的操作,基本上,先实现svn自动同步更新到web测试目录,需要做几件事(使用https安全链接方式,可能使用非安全链接的http方式可能比较省事)

1.确保你的svn启动用户和用户组具有对web目录的可读写权限。

2.确保你的帐号密码是正确并有权限访问svn(只需要只读权限就可以)

送上一个post-commit钩子脚本,没有标点符号错误哦,哈哈,你需要将你的路径和帐号密码对应改一下

“C:\Program Files\VisualSVN Server\bin\svn.exe” update “D:\yyyy\xxx” –non-interactive –trust-server-cert –no-auth-cache –username 11111111 –password 22222

 

 

该日志未加标签

添加一条评论 »本文共 3 条评论

  1. 还有参数应该是– 最后一条命令也是全角的

  2. 最后一条脚本的引号是全角的, 作者是故意的吗?

Deepseath Modified from Green Hope Theme · Proudly powered by WordPress · 津ICP备09005418号-1  津公网安备 12010302001005号