4

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

bahrep
  • 29,961
  • 12
  • 103
  • 150
Erik
  • 5,039
  • 10
  • 63
  • 119

1 Answers1

4
  • 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?

bahrep
  • 29,961
  • 12
  • 103
  • 150
  • Updated my question with a picture. In the picture i thought i hade set the permissions right. In the picture, is that the VisualSvn "service account"?? – Erik Jan 23 '12 at 09:09
  • 1
    No, the account you show on the permissions dialog is the `VisualSVN Server Admins`. This account is used to provide domain users with remote access to VisualSVN Server with VisualSVN Server Manager. – bahrep Jan 23 '12 at 09:16
  • 2
    To verify what account is used to run VisualSVN Server service you should go to `services.msc`, find **VisualSVN Server** on the list and check it's 'Log On' setting. By default it should be `Network Service` (however in Swedish it may be spelled differently). – bahrep Jan 23 '12 at 09:23
  • yes it's "Network Service (Nätverkstjänst)" as you say when i look in the services.msc. I set full permission but no triggering happens. Just like the picture show. Any more ides? – Erik Jan 23 '12 at 20:40
  • 1
    Check the folder permissions: F:\Repositories\, f:\druidBACKUP\SVN\, f:\druidBACKUP\SVN\. Do VisualSVN Server service account ("Network Service (Nätverkstjänst)") have permissions to access these folders? – bahrep Feb 01 '12 at 13:22
  • I try to set permission on the desired location folder but i cannot add Nätverkstjänst. The folder is a mapped network folder from my NAS server. Was thinking that by mapping it i would not have to set any permission and i cannot do it anyway, the "new" permission disappear when i close the dialoge. – Erik Feb 01 '12 at 20:28
  • Mapped network drives **are not supported** as they are mapped on a per-user basis and are not available for built-in accounts such as `Network Service` (`Nätverkstjänst`) and the issue occurs. Please use UNC path in hook (like _\\server\share_). You may verify UNC path to repositories though **VisualSVN Server Manager** | **Propeties**. – bahrep Feb 03 '12 at 11:37
  • I try the UNC path but nothing happens. The path is to a NAS server and need login user/pass. Can i include some user/passw in this "SET repodirhot=\\druidBACKUP\SVN\" – Erik Feb 03 '12 at 19:59
  • @bahrep, Thank you for your comments related to `NETWORK SERVICE` file permission. – Mansoorkhan Cherupuzha Jul 25 '13 at 11:33