I have installed and set up the VisualSVN Server v3.2.2 on my local machine (Windows 7 Professional - 64bit) and I wrote post-commit hook in Perl which basically should send one HTTP POST request to some server every time something was commited. I have tested my Perl script through cmd and I am getting valid response, but when I commit something using TortoiseSVN client I get Errors
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.
Here is my perl script:
$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);
and my post-commit batch file:
perl myhook.pl %1 %2
I have tried to restart svn server and my machine, but with no luck.
Also when I type path
in cmd I do see perl in my path C:\Perl64\bin
Maybe my approach for this hook is not right or something ... anyone can help with this one?
Thanks
Your PATH
is not the same PATH
that the user account under which VisualSVN Server runs has.
Always specify the full, absolute path to all items in your hook scripts, regardless of what SVN server and OS you're using.
C:\Perl64\bin\perl myhook.pl %1 %2