2

So I've got a basic post-commit hook written in ruby, and I've confirmed it runs when I commit from the command line. It does not, however, run when I commit in Git Tower, and I don't even see any errors from Git Tower appear.

My script begins with: #!/usr/bin/env ruby and it does run properly when I commit from the command line, so I know its not a problem with the script. Do I need to do something to get my gems to load properly?

Samuel Kordik
  • 131
  • 1
  • 5
  • Following https://github.com/resmo/git-ftp/issues/221, would a simpler shell script work? `#!/bin/sh echo "test" >> "post-commit.log" 2>&1` – VonC May 29 '13 at 05:44

1 Answers1

0

The only explanation would be that the Git Tower doesn't run in the same shell, with the same environment.

See its FAQ "Are Hook scripts supported in Tower?"

Please note: Do your hook scripts rely on the existence or on specific values of shell environment variables that are created/modified in your shell profile (like extending "PATH" by a non-standard-path (e.g. '~/bin') to run a script from there in the hook)?

If the answer is yes, then you need to make sure you're creating the required shell environment in the hook script itself (like modifying "PATH"), not in your shell profile, as the hook script is called from the Tower process environment which is not running in a shell environment (hence your shell profile is not loaded).

In that case, a simple shell script should be your post-commit hook, in order to:

  • modify the environment appropriately
  • call your ruby script.
Alexandre Hamez
  • 7,725
  • 2
  • 28
  • 39
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250