我已经在我的本地机器( Windows 7 Professional - 64bit )上安装并设置了 VisualSVN Server v3.2.2,并且我在 Perl 中编写了 post-commit 钩子,它基本上应该在每次提交某些内容时向某个服务器发送一个 HTTP POST 请求。我已经通过 cmd 测试了我的 Perl 脚本并且我得到了有效的响应,但是当我使用 TortoiseSVN 客户端提交某些内容时,我得到了错误
Error post-commit hook failed (exit code 1) with output:
'perl' is not recognized as an internal or external command,
operable program or batch file.
这是我的 perl 脚本:
$svnlook = '"C:\Program Files\VisualSVN Server\bin\svnlook.exe"';
$repos = $ARGV[0];
$txn = $ARGV[1];
print STDOUT "message sent " . $repos . " " . $txn;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $server_endpoint = "http://jsonplaceholder.typicode.com/posts";
# set custom HTTP request header fields
my $req = HTTP::Request->new(POST => $server_endpoint);
$req->header('content-type' => 'application/json');
# add POST data to HTTP request body
my $post_data = '{ "repos":"' . $repos . '", "txn":"' . $txn . '"}';
$req->content($post_data);
my $resp = $ua->request($req);
if ($resp->is_success) {
my $message = $resp->decoded_content;
print "Received reply: $message\n";
}
else {
print "HTTP POST error code: ", $resp->code, "\n";
print "HTTP POST error message: ", $resp->message, "\n";
}
exit(0);
和我的提交后批处理文件:
perl myhook.pl %1 %2
我试图重新启动 svn 服务器和我的机器,但没有运气。此外,当我输入path
cmd 时,我确实在我的路径中看到 perlC:\Perl64\bin
也许我对这个钩子的方法不正确或者什么......任何人都可以帮助这个吗?
谢谢