Question

I'm trying to call a script using a post-commit hook, but it fails because it cannot find various commands.

My research has shown that there are basically no environment variables loaded when a post-commit hook is run, so I suppose that's why it can't find commands like ping.

Is there anyway to define enough in my post-commit hook so that I can call a script that runs on baseline POSIX commands?

Was it helpful?

Solution

Subversion hook scripts are executed with an empty environment. Best practice is to specify full paths in your scripts (and any other scripts that they may call), or set up the environment variables you require in the hook script itself.

From the manual:

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.

OTHER TIPS

At the start of your hook, you can set up PATH and other environment variables:

LANG=en_US.UTF-8
PATH=/path/to/bin:/another/bin:$PATH
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top