svn - 如何编写提交后钩子(Hook)来自动同步两个存储库

标签 svn ssl version-control

我正在尝试使用 subversion (SVN) 同步两个存储库,并在源服务器和镜像服务器上使用 visualSVN。

我可以手动同步它们,即通过命令行,但我希望使用主存储库的提交后 Hook 自动触发它。

我在源仓库(master)的post-commit钩子(Hook)中写了下面的代码来自动与镜像仓库(slave)同步:

svnsync --non-interactive --sync-username syncuser --sync-password syncuserpassword sync mirror-repository-url

但是当我将一些文件 checkin 源存储库(master)时,它显示以下错误:

**post-commit hook failed(exit code 1) with output:

svnsync:E230001:Unable to connect to a repository at URL 'mirror-repository-url' svnsync:E230001:Server SSL certificate verification failed; Certificate issued for a different hostname; issuer is not trusted**

但是我在 SVN(主)的源存储库中获取文件,但没有到镜像存储库(从),所以我尝试手动提供相同的代码,该代码是通过命令行的主存储库的提交后 Hook 编写的镜像服务器,然后镜像存储库(从)与添加到源存储库(主)的新修订同步

如何在使用提交后 Hook 自动同步时克服这个问题?我哪里做错了?你能提出一些想法来克服这个错误吗?

最佳答案

so i tried manually giving the same code which was written in post-commit hook of master repository through command line of the mirror server

首先,您在错误的服务器上进行测试。如果在主服务器上执行提交后 Hook 有问题,那么您应该在主服务器上测试您的命令。

通常当您看到命令行和提交后 Hook 上下文中的行为差异时,这与没有设置环境变量有关。来自SVN book section on hooks :

For security reasons, the Subversion repository executes hook programs with an empty environment—that is, no environment variables are set at all, not even $PATH (or %PATH%, under Windows). Because of this, many administrators are baffled when their hook program runs fine by hand, but doesn't work when run by Subversion. Be sure to explicitly set any necessary environment variables in your hook program and/or use absolute paths to programs.

关于svn - 如何编写提交后钩子(Hook)来自动同步两个存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26362689/

相关文章:

svn - 用 git-svn cherry-pick

java - svnkit:如何枚举根目录中的svn存储库?

c# - SharpSVN 读取所有文件名

git - 如何在提交前查看 'git svn dcommit' 的变化?

http - 无法使用 jmeter 打开特定的 HTTPS 页面

android - 不同证书的apk

ssl - 如何像浏览器一样使用openssl验证证书?

linux - 如何通过ftp进行版本控制?

version-control - 忽略 TortoiseHg 中的提交

git - 如何撤消 git push -u origin my_branch?