Question

I want to update remote staging server automatically after committing on my dev box. I'm trying to setup TortoiseSVN post-commit hook on Win 7 64. I have TortoiseGit installed in system with bunch of useful commands like 'ssh'

I created test.bat script that contains:

ssh -l {username} -i "C:\Users\{path-to-ssh-key.pem}" {server_address} ./svnup

This script running 'svn up' on remote staging server. And this test.bat file works fine when launched manually. But it not works in post-commit configuration. Blank console screen appearing and than TortoiseSVN showing an error:

Error: The hook script returned an error:    
Error:       0 [main] ssh 2040 fhandler_base::dup: dup(some disk file) failed, handle 0, Win32 error 6    
Error: dup() in/out/err failed

Could you advice?

UPD: I upgraded batch script to use full path.

"C:\Program Files (x86)\Git\bin\ssh.exe" -l {username} -i "C:\Users\{path-to-ssh-key.pem}" {server_address} ./svnup

But error still there. Now it has some new number

Error: The hook script returned an error:  
Error:       0 [main] ssh.exe" 6976 fhandler_base::dup: dup(some disk file) failed, handle 0, Win32 error 6  
Error: dup() in/out/err failed  
Was it helpful?

Solution 3

Solution is to use plink.exe instead TortoiseGit ssh.exe. And this will work:

c:\plink.exe -ssh -batch -l {username} -i "C:\Users\{path-to-ssh-key.pem}" {server_address} ./svnup

OTHER TIPS

Your hook probably cannot find ssh.

Using the full path name can help.

If that doesn't help changing the working directory to the location of ssh can help.

In the worst case you could add the location of ssh to the path, from within the batch file. This will only affect the path, during execution. I believe that a new shell is created by tortoise each time it's called.

As mentioned in the svn book:

For security reasons, the Subversion repository executes hook programs with an empty environment—that is, no environment variables are set at all, not even $PATH (or %PATH%, under Windows). Because of this, many administrators are baffled when their hook program runs fine by hand, but doesn't work when run by Subversion. Be sure to explicitly set any necessary environment variables in your hook program and/or use absolute paths to programs.

Which means your hook script doesn't know where to find ssh and what the current directory is (so using relative paths most likely won't work either).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top