简体   繁体   English

SVN Post Commit Hook Batch Windows

[英]SVN Post Commit Hook Batch Windows

I have a Windows Server running Visual SVN Server to store our repositories. 我有一台运行Visual SVN Server的Windows Server来存储我们的存储库。 Also on that server is our test copy. 该服务器上还有我们的测试副本。

I'm trying to set up a simple SVN post-commit hook so it updates that test copy automatically every time I commit something 我正在尝试设置一个简单的SVN post-commit钩子,以便每次我提交时自动更新该测试副本

In Visual SVN in the post-commit hooks I've set up like this 在后提交钩子中的Visual SVN中,我设置了这样的

"C:\Program Files (x86)\VisualSVN Server\bin\updatescripts.bat" D:\inetpub\TESTCOPY

Then that batch file has a simple update like this 然后该批处理文件有一个像这样的简单更新

PATH=%PATH%;"C:\Program Files (x86)\VisualSVN Server\bin\"
svn update %1

If I run the batch file in the server by double clicking on it or from command line works fine. 如果我通过双击它或从命令行运行服务器中的批处理文件工作正常。 When committing something from my laptop it freezes and doesn't give me any error and locks the test copy so then I need to go in and run a clean up. 当从我的笔记本电脑上提交某些内容时,它会冻结并且不会给我任何错误并锁定测试副本,因此我需要进入并进行清理。

Visual SVN service is running as network service and this aacount has full access to the bin folder and the test copy on the server. Visual SVN服务作为网络服务运行,并且此aacount可以完全访问服务器上的bin文件夹和测试副本。

Any idea how to set up a simple svn update post commit hook anyone? 任何想法如何设置一个简单的svn更新post post hook任何人?

Thanks Fede 谢谢联邦

I had a similar problem and it turned out to be that SVN likes paths to use forward slashes instead of backslashes. 我遇到了类似的问题,结果证明SVN喜欢使用正斜杠而不是反斜杠的路径。

Try this: 尝试这个:

set MYPATH=%1

:: Transform backslashes to forward slashes
set MYPATH=%MYPATH:^\=/%

svn update %MYPATH%

You're running the svn update command. 您正在运行svn update命令。 Exactly what working copy are you trying to update? 您正在尝试更新的工作副本到底是什么?

The parameter being passed is the Repository's path . 传递的参数是Repository的路径 This points not to a working directory, but to the directory that contains the Subversion master repository. 这不是指向工作目录,而是指向包含Subversion主存储库的目录。 This is the same directory where your post commit hook is stored. 这是存储post commit钩子的目录。

Subversion hooks do not have access to the user's working directory, so you can't manipulate the user's files. Subversion挂钩无法访问用户的工作目录,因此您无法操纵用户的文件。 Hook scripts usually should be using svnlook and not svn . 钩子脚本通常应该使用svnlook而不是svn By doing this, you prevent yourself from getting into any sort of trouble. 通过这样做,您可以防止自己陷入任何麻烦。

It is possible to update a Subversion working copy on the server, if you know the location: 如果您知道位置,则可以在服务器上更新Subversion工作副本:

PATH=%PATH%;"C:\Program Files (x86)\VisualSVN Server\bin\"
set SVN_WORK_DIR=C:\SVN\workdir"
svn update %SVN_WORK_DIR%

However, I wouldn't recommend this because it ties up Subversion. 但是,我不推荐这个,因为它绑定了Subversion。 The user who did the commit would have to wait until the update is complete before Subversion returns the control of the prompt back to the user. 执行提交的用户必须等到更新完成,然后Subversion才会将提示控件返回给用户。

After trying a million different things this worked for me... 在尝试了一百万种不同的东西后,这对我有用......

I put this in my post-commit hook "C:\\Program Files\\VisualSVN Server\\bin\\svn.exe" update "C:\\my path\\" where my path is the path to the working copy to be updated 我把它放在我的post-commit钩子“C:\\ Program Files \\ VisualSVN Server \\ bin \\ svn.exe”更新“C:\\ my path \\”,其中我的路径是要更新的工作副本的路径

Also I had to change the service to run as local system 此外,我不得不将服务更改为本地系统运行

That is really not the way you want to do that. 真的不是你想要那样做的方式。 What you should do is use something like Jenkins to watch your repository. 你应该做的是使用像詹金斯这样的东西来观察你的存储库。 Jenkins can watch your repository, and it when it changes, update your test copy, kick-off builds, run automated tests, etc. Jenkins可以监视您的存储库,它可以在更改时更新,更新测试副本,启动构建,运行自动化测试等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM