1

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

alroc
  • 27,574
  • 6
  • 51
  • 97
Darko Rodic
  • 1,010
  • 3
  • 10
  • 27

1 Answers1

4

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
alroc
  • 27,574
  • 6
  • 51
  • 97
  • Thanks for fast response, but now I am getting other strange error: Error: post-commit hook failed (exit code 2) with output: Can't open perl script "myhook.pl": No such file or directory when myhook.pl is in same folder as post-commit.cmd – Darko Rodic Mar 13 '15 at 11:16
  • Like I said, you need to specify the **full path to all items**. I don't know the path to `myhook.pl`, so I couldn't put it in my post. – alroc Mar 13 '15 at 11:22