Applies to: VisualSVN Server 5.2 and later
VisualSVN Server provides a VisualSVNServerHooks run
hook
subcommand for launching arbitrary applications and scripts in repository
hooks. Programs can be started synchronously, meaning they start and the
hook waits for their completion, or asynchronously, meaning they start and
the hook doesn't wait for their completion.
run
subcommand can be used with any type of repository
hook (e.g., it can be used in pre-commit hooks, post-commit hooks,
pre-revprop-change hooks, pre-lock hooks, or in any other hooks).
The run
command accepts the following options:
Option | Meaning |
--no-wait | Do not wait for the program to complete. I.e., start the program asynchronously. |
--log-dir ARG | Specify this option to save the program's output into the specified directory. By default, the output isn't saved. |
--log-name-prefix ARG | Specify the log filename prefix. By default, the value is
'VisualSVNServerHooks'. Use this option when --log-dir is enabled. |
--program ARG | Specify the program to start. This must be the last option, because all of the following characters will be interpreted as the program name and its arguments. |
Examples
Below you can find examples of scripts that you can use in your repositories:
--program
option must be the last option of the run
subcommand. All the characters after the option are interpreted as the
option's argument.
Start the specified application and wait for it to complete
Use the following script to start the my-hook-handler.exe
program synchronously. The example assumes that the executable file
my-hook-handler.exe
is located in the /hooks
directory of the repository.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" run ^ --program "%~dp0\my-hook-handler.exe" %* IF ERRORLEVEL 1 exit /b 1
Start the specified application without waiting for it to complete
Use the following script to start the my-hook-handler.exe program
asynchronously. The example assumes that the executable file
my-hook-handler.exe
is located in the /hooks
directory of the repository.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" run --no-wait ^ --program "%~dp0\my-hook-handler.exe" %* IF ERRORLEVEL 1 exit /b 1
Start the specified PowerShell script without waiting for it to complete
Use the following script to start the my-hook-handler.ps1
PowerShell script asynchronously. The example assumes that the
PowerShell script file my-hook-handler.ps1
is located in the
/hooks
directory of the repository.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" run --no-wait ^ --program powershell -File "%~dp0\my-hook-handler.ps1" %* IF ERRORLEVEL 1 exit /b 1
Start the specified application and save its output into a directory
Use the following script to start the my-hook-handler.exe
program asynchronously and log its standard and error output into files
in the my-hook-logs/
directory.
The example assumes that the executable file my-hook-handler.exe
and the log directory my-hook-logs
are located in the
/hooks
directory of the repository.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" run ^ --no-wait ^ --log-dir %~dp0\my-hook-logs ^ --log-name-prefix my-hook-handler-prefix ^ --program "%~dp0\my-hook-handler.exe" %* IF ERRORLEVEL 1 exit /b 1