Environment in external Mercurial hooks
The repository has some external changegroup hooks. These hooks rely on some environment variables, e.g., JAVA_HOME defined for the user that runs SCM-manager. But these variables are not present in the environment during hook execution in case the push is done via HTTP (i.e., via SCM-Manager). Here is a minimal example to illustrate the problem:
In repository .hg/hgrc I have
[hooks] changegroup.scm = python:scmhooks.callback pretxnchangegroup.scm = python:scmhooks.callback changegroup.log = echo "JAVA_HOME: $JAVA_HOME"
If I push localy from another repository located on the same server then everything works as expected:
hg push /repo/hg/test --config hooks.changegroup.scm="" --config hooks.pretxnchangegroup.scm="" pushing to /repo/hg/test searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files JAVA_HOME: /usr/java/latest
So JAVA_HOME is in the environment and therefore printed (I've disabled SCM system hooks here). But if I push from remote location via HTTPS then I get:
hg push pushing to https://repo.webmedia.eu/hg/test searching for changes remote: adding changesets remote: adding manifests remote: adding file changes remote: added 1 changesets with 1 changes to 1 files remote: JAVA_HOME:
So the environment doesn't include such variable. And if I print the output of the "env" command in a hook then the output is also quite different.
In the first case I was logged in as the same user that SCM-manager is being run as.
Does SCM-manager create some kind of sandbox execution environment when running hooks?
Some installation details:
OS is CentOS 6.2.
SCM-manager version is 1.14.
SCM-manager runs in the background using this approach: https://groups.google.com/forum/#!topic/scmmanager/-wNjenUbl0Q.
JAVA_HOME is defined in /.bash_profile. Declaring it in /etc/init.d/scmserver or bin/scm-server doesn't have effect.