我在Windows服务器上运行VisualSVN。
我正在尝试添加一个提交后钩子,以便在发生提交时更新我们的阶段项目。
在VisualSVN中,如果我在hook/post-commit对话框中输入命令,一切都会正常工作。
但是,如果我使用完全相同的命令创建一个批处理文件,我会得到一个错误,指出提交后钩子失败。没有其他信息。
我的命令使用绝对路径。
我尝试将批处理文件放在VisualSVN/bin目录中,在那里我得到了相同的错误。
我已经确保VisualSVN拥有批处理文件所在目录的权限。
我唯一能想到的就是我没有从VisualSVN中正确地调用它。我只是用批处理文件名("c:\VisualSVN\bin\my- batch -file.bat")替换钩子/提交后对话框中的svn update命令。
我是否需要在SVNCommit对话框中使用不同的语法来调用批处理文件?在批处理文件中(它只有我的svn update命令。如果我从命令行运行批处理文件,它就可以工作。)
最终,我想使用批处理文件,因为我想在提交之后做更多的事情。
发布于 2017-10-17 23:19:38
当使用VisualSVN >时,选择Repo > Properties > Hooks > Post-commit挂钩。其中的代码用于发送电子邮件,然后运行脚本,该脚本包含我想要自定义的命令
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" ^
commit-notification "%1" -r %2 ^
--from support@domainname.com --to "support@domainname.com" ^
--smtp-server mail.domainname.com ^
--no-diffs ^
--detailed-subject
--no-html
set PWSH=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe
%PWSH% -command $input ^| C:\ServerScripts\SVNScripts\post-commit-wp.ps1 %1 %2
if errorlevel 1 exit %errorlevel%脚本文件位于C:\ServerScripts\SVNScripts\ post-commit-wp.ps1,我传入了两个VisualSVN变量%1和%2
修订号%1= serverpathwithrep
脚本文件是用PowerShell编写的
# PATH TO SVN.EXE
$svn = "C:\Program Files\VisualSVN Server\bin\svn.exe"
$pathtowebistesWP = "c:\websites-wp\"
# STORE HOOK ARGUMENTS INTO FRIENDLY NAMES
$serverpathwithrep = $args[0]
$revision = $args[1]
# GET DIR NAME ONLY FROM REPO-PATH STRING
# EXAMPLE: C:\REPOSITORIES\DEVHOOKTEST
# RETURNS 'DEVHOOKTEST'
$dirname = ($serverpathwithrep -split '\\')[-1]
# Combine ServerPath with Dir name
$exportpath = -join($pathtowebistesWP, $dirname);
# BUILD URL TO REPOSITORY
$urepos = $serverpathwithrep -replace "\\", "/"
$url = "file:///$urepos/"
# --------------------------------
# SOME TESTING SCRIPTS
# --------------------------------
# STRING BUILDER PATH + DIRNAME
$name = -join($pathtowebistesWP, "testscript.txt");
# CREATE FILE ON SERVER
New-Item $name -ItemType file
# APPEND TEXT TO FILE
Add-Content $name $pathtowebistesWP
Add-Content $name $exportpath
# --------------------------------
# DO EXPORT REPOSITORY REVISION $REVISION TO THE ExportPath
&"$svn" export -r $revision --force "$url" $exportpath我添加了注释来解释每一行以及它的作用。简而言之,脚本:
这是一种将新提交的代码部署到网站的简单方法。
发布于 2010-06-24 00:08:04
您是否尝试使用'call‘命令执行批处理文件?我的意思是:
call C:\Script\myscript.bat发布于 2013-03-14 01:27:24
我尝试了同样的方法,发现您还必须将脚本放在hooks文件夹中。这就是bat文件。
https://stackoverflow.com/questions/3101948
复制相似问题