2015-03-13 114 views
1

我已經在本地機器上安裝並設置了VisualSVN Server v3.2.2(Windows 7 Professional - 64bit),並且我編寫了Perl中的post-commit hook基本上應該在每次提交事件時向某個服務器發送一個HTTP POST請求。 我已經通過CMD測試我的Perl腳本,我得到有效的響應,但是當我使用TortoiseSVN客戶端提交的東西我得到的錯誤VisualSVN服務器無法識別提交後鉤子中的Perl

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服務器和我的機器,但沒有運氣。 此外,當我在cmd中輸入path我看到的Perl在我的道路C:\Perl64\bin

也許我的這種做法掛鉤是不正確或東西...任何人都可以用這一個幫助?

感謝

回答

4

PATH不是在其下VisualSVN服務器上運行的用戶帳戶具有相同的PATH

無論您使用的是什麼SVN服務器和操作系統,始終指定鉤子腳本中所有項目的完整絕對路徑。

C:\Perl64\bin\perl myhook.pl %1 %2 
+0

感謝響應速度快,但現在我得到其他奇怪的錯誤: 錯誤:post-commit鉤子失敗(退出代碼2)輸出:無法打開Perl腳本「myhook.pl」:沒有這樣的文件或目錄 當myhook.pl與post-commit.cmd位於同一文件夾 – 2015-03-13 11:16:00

+0

就像我說的,你需要指定所有項目的**完整路徑**。我不知道'myhook.pl'的路徑,所以我不能把它放在我的帖子中。 – alroc 2015-03-13 11:22:23

+0

哦,是的,所有的項目...對不仔細閱讀。 – 2015-03-13 11:25:25

相關問題