Search code examples
javagitatlassian-sourcetree

SourceTree pre-commit fails for java


I have a very simple pre-commit:

PATH=$PATH:/usr/local/bin:/usr/local/sbin
./mvnw test
mvn test

when I run from command line git commit everything is grand.

However when I try to commit in sourcetree it fails with this error:

Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
No Java runtime present, requesting install.
.git/hooks/pre-commit: line 3: mvn: command not found

which suggests it doesn't pickup my $JAVA_HOME or able to find that mvn is installed on this machineI added the top line to the pre-commit. Any ideas how sourcetree can be passed this info?


Solution

  • Found the answer was to open the app from the command line:

    open /Applications/SourceTree.app/Contents/MacOS/SourceTree

    answer was found here:

    https://community.atlassian.com/t5/Bitbucket-questions/SourceTree-Hook-failing-because-paths-don-t-seem-to-be-set/qaq-p/274792