如何在 win7 64 位中设置 VisualSVN 提交后挂钩

发布于 2024-12-28 04:05:12 字数 4105 浏览 3 评论 0原文

我的提交后挂钩从未被触发,我认为这是因为
我需要设置一些文件系统权限。

我安装了 VisualSVN-Server-2.5.2 并使用 Subversion 插件运行 eclipse。

除了 VisualSVN 挂钩触发之外,一切都按预期工作。

这是我的 post-commit.cmd 文件,名称为“post-commit.cmd”

C:\PROGRA~2\VISUAL~1\bin\myScript.cmd 
exit 0

更新 1 当我像这样输入“开始”文本时,“提交”窗口会冻结并显示一个脉动的进度绿色条,就像它在等待钩子触发或其他什么一样。我不能
取消提交操作,但我可以关闭 Eclipse,然后硬终止提交窗口。

start C:\PROGRA~2\VISUAL~1\bin\post-commit.cmd
exit 0

更新2

如果将存储库保存到本地硬盘,它就可以工作。当保存路径用于网络驱动器时,它不起作用。好吧,这是向前迈出的一步。浴文件可能需要一些用户/密码

这是将存储库保存到本地硬盘的bat文件(感谢Christopher C. Simmons(CCS))

@ECHO OFF
CLS
:: =================== COPYRIGHT ========================================= 
:: File:          svn_backup.bat
:: Author:        Christopher C. Simmons (CCS)
:: Date:          05.01.2008
:: Purpose:       To make backups ("hot copies") of multiple SVN repos
:: History:       0.1 Initial Release
:: Assumes:       Your path contains: C:\Program Files\Subversion\bin
::                Your repodir contains only repos
:: Copyright:     2008 csimmons.net
::                
:: NOTICE!!!
:: csimmons.net, LLC supplies this software AS IS and makes no guarantees
:: for your use of it. csimmons.net, LLC is not responsible for any damage
:: or pain the use of this product may cause you.  Please give credit if 
:: you use this or create a derivative work.
:: =================== COPYRIGHT =========================================

:: =================== CONFIG ============================================
:: Path of the dir containing your repos [Note Trailing slash]
SET repodir=F:\Repositories\
:: Path of the dir in which to create you hotcopies [Note Trailing slash]
SET repodirhot=f:\druidBACKUP\SVN\
:: Path for log file [Note Trailing slash]
SET logdir=f:\druidBACKUP\SVN\
:: Path for svnadmin [Note Trailing slash]
::SET svnpath=C:\PROGRA~2\VISUAL~1\bin\svnadmin.exe
:: User mode - 1=Interactive | 0=NonInteractive
SET imode=1
:: =================== CONFIG ============================================

:: =================== SCRIPT ============================================
:: !!! NO NEED TO EDIT BEYOND THIS POINT !!!

:: Make a date_time stamp like 030902_134200
SET hh=%time:~0,2%

:: Add a zero when this is run before 10 am.
IF "%time:~0,1%"==" " set hh=0%hh:~1,1%
SET yymmdd_hhmmss=%date:~12,2%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2%

:: Make a name for the log file
SET repolog=%logdir%%yymmdd_hhmmss%repobackup.log

:: Start log
ECHO START %date% %time% >> %repolog%

:: IF a  hotcopy exists delete it first ELSE
:: Create directories and svn hotcopy repos to them
FOR /F %%G IN ('dir /b /ad %repodir%') DO ^
IF EXIST %repodirhot%%%G (rmdir /S /Q %repodirhot%%%G & mkdir %repodirhot%%%G >> %repolog% & ^
ECHO Starting SVN backup for %%G... >> %repolog% & ^
C:\PROGRA~2\VISUAL~1\bin\svnadmin hotcopy %repodir%%%G %repodirhot%%%G --clean-logs >> %repolog% & ^
IF %imode%== 1 ECHO FINISHED...%%G) ^
ELSE (mkdir %repodirhot%%%G >> %repolog% & ^
ECHO Starting SVN backup for %%G... >> %repolog% & ^
C:\PROGRA~2\VISUAL~1\bin\svnadmin hotcopy %repodir%%%G %repodirhot%%%G --clean-logs >> %repolog% & ^
IF %imode%== 1 ECHO FINISHED...%%G)

:: Finish log
ECHO END %date% %time% >> %repolog%
:: Display log message if interactive mode otherwise EXIT
ECHO Done... Logs available here: %repolog% 
if %imode%== 1 pause
:: =================== SCRIPT ============================================
EXIT 

这个想法是启动一个更大的脚本myScript.cmd女巫正在做
我的存储库。如果我手动启动 post-commit.cmd

阅读此处的手册, 这是有效的 visualsvn.com

我不明白如何处理下面的文本。

“Subversion 与拥有访问 Subversion 存储库的进程的同一用户执行挂钩。在大多数情况下,存储库是通过 Subversion 服务器访问的,因此该用户与系统上运行服务器的用户是同一用户。钩子本身需要配置操作系统级别的权限,以允许用户执行它们,这意味着由钩子直接或间接访问的任何程序或文件(包括 Subversion 存储库)都将以同一用户的身份进行访问。换句话说,要警惕潜在的与权限相关的问题可能会阻止挂钩执行其设计执行的任务。”

更新 设置权限

My post-commit hook is never triggered and i think it's because
there is some filesystem permissions i need to set.

I have VisualSVN-Server-2.5.2 installed and running eclipse with Subversion pluggin.

Everything is working as expected except for the VisualSVN hook triggering.

This is my post-commit.cmd file with the name "post-commit.cmd"

C:\PROGRA~2\VISUAL~1\bin\myScript.cmd 
exit 0

UPDATE 1
when i put the "start" text like this the Commit window freezes with a pulsating progress-green bar, like it waiting for the hook triggering or somehing.I cannot
cancel commit operation but i can close eclipse and then hard-kill the commit window.

start C:\PROGRA~2\VISUAL~1\bin\post-commit.cmd
exit 0

UPDATE 2

It's working if a save the repository to local hdd. It's when save-path is for network drive that its not working. Ok that's a forward step. the bath file need some user/password maybe

Here's the bat file that saves the repository to local hdd(thanks to Christopher C. Simmons (CCS))

@ECHO OFF
CLS
:: =================== COPYRIGHT ========================================= 
:: File:          svn_backup.bat
:: Author:        Christopher C. Simmons (CCS)
:: Date:          05.01.2008
:: Purpose:       To make backups ("hot copies") of multiple SVN repos
:: History:       0.1 Initial Release
:: Assumes:       Your path contains: C:\Program Files\Subversion\bin
::                Your repodir contains only repos
:: Copyright:     2008 csimmons.net
::                
:: NOTICE!!!
:: csimmons.net, LLC supplies this software AS IS and makes no guarantees
:: for your use of it. csimmons.net, LLC is not responsible for any damage
:: or pain the use of this product may cause you.  Please give credit if 
:: you use this or create a derivative work.
:: =================== COPYRIGHT =========================================

:: =================== CONFIG ============================================
:: Path of the dir containing your repos [Note Trailing slash]
SET repodir=F:\Repositories\
:: Path of the dir in which to create you hotcopies [Note Trailing slash]
SET repodirhot=f:\druidBACKUP\SVN\
:: Path for log file [Note Trailing slash]
SET logdir=f:\druidBACKUP\SVN\
:: Path for svnadmin [Note Trailing slash]
::SET svnpath=C:\PROGRA~2\VISUAL~1\bin\svnadmin.exe
:: User mode - 1=Interactive | 0=NonInteractive
SET imode=1
:: =================== CONFIG ============================================

:: =================== SCRIPT ============================================
:: !!! NO NEED TO EDIT BEYOND THIS POINT !!!

:: Make a date_time stamp like 030902_134200
SET hh=%time:~0,2%

:: Add a zero when this is run before 10 am.
IF "%time:~0,1%"==" " set hh=0%hh:~1,1%
SET yymmdd_hhmmss=%date:~12,2%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2%

:: Make a name for the log file
SET repolog=%logdir%%yymmdd_hhmmss%repobackup.log

:: Start log
ECHO START %date% %time% >> %repolog%

:: IF a  hotcopy exists delete it first ELSE
:: Create directories and svn hotcopy repos to them
FOR /F %%G IN ('dir /b /ad %repodir%') DO ^
IF EXIST %repodirhot%%%G (rmdir /S /Q %repodirhot%%%G & mkdir %repodirhot%%%G >> %repolog% & ^
ECHO Starting SVN backup for %%G... >> %repolog% & ^
C:\PROGRA~2\VISUAL~1\bin\svnadmin hotcopy %repodir%%%G %repodirhot%%%G --clean-logs >> %repolog% & ^
IF %imode%== 1 ECHO FINISHED...%%G) ^
ELSE (mkdir %repodirhot%%%G >> %repolog% & ^
ECHO Starting SVN backup for %%G... >> %repolog% & ^
C:\PROGRA~2\VISUAL~1\bin\svnadmin hotcopy %repodir%%%G %repodirhot%%%G --clean-logs >> %repolog% & ^
IF %imode%== 1 ECHO FINISHED...%%G)

:: Finish log
ECHO END %date% %time% >> %repolog%
:: Display log message if interactive mode otherwise EXIT
ECHO Done... Logs available here: %repolog% 
if %imode%== 1 pause
:: =================== SCRIPT ============================================
EXIT 

The idea is to launch a larger script myScript.cmd witch are doing the hotcopy of
my repository. This is working if i manually start the post-commit.cmd

reading the manual here
visualsvn.com

I cannot understand what to practically do regarding this text below.

"Subversion executes hooks as the same user who owns the process that is accessing the Subversion repository. In most cases, the repository is being accessed via a Subversion server, so this user is the same user as whom the server runs on the system. The hooks themselves will need to be configured with OS-level permissions that allow that user to execute them. Also, this means that any programs or files (including the Subversion repository) accessed directly or indirectly by the hook will be accessed as the same user. In other words, be alert to potential permission-related problems that could prevent the hook from performing the tasks it is designed to perform."

UPDATE Permission to set

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独患者 2025-01-04 04:05:12
  • VisualSVN Server 服务在 Network Service 帐户下运行
    默认或专用自定义帐户(应创建
    手动)。

  • Subversion 挂钩在 VisualSVN Server 服务下执行
    帐户(网络服务或专用帐户)

如果手动启动时挂钩脚本正常工作,我建议您检查服务帐户的权限。它应该有权访问“C:\PROGRA~2\VISUAL~1\bin\myScript.cmd”以及涉及的所有其他文件。

另请注意,在 Subversion 调用挂钩脚本之前,它会从环境中删除所有变量(包括 Windows 上的 %PATH%)。因此,如果您拼写出另一个程序的绝对名称,您的脚本只能运行该程序。

Subversion 常见问题解答:为什么我的存储库挂钩不起作用?

  • VisualSVN Server service runs under Network Service account by
    default or under dedicated custom account (should be created
    manually).

  • Subversion hooks are executed under the VisualSVN Server service
    account (Network Service or dedicated account)

If the hook script works properly when you start it manually, I advise you to check the permissions for the service account. It should have access to 'C:\PROGRA~2\VISUAL~1\bin\myScript.cmd' and all other files involved.

Please also note that before Subversion calls a hook script, it removes all variables -- including %PATH% on Windows -- from the environment. Therefore, your script can only run another program if you spell out that program's absolute name.

Subversion FAQ: Why aren't my repository hooks working?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文