简体   繁体   English

Intellij Idea无法执行git pre-push hook

[英]Intellij Idea not able to execute git pre-push hook

I would like to execute a git pre-push hook from the IntelliJ IDEA. 我想从IntelliJ IDEA执行一个git pre-push hook。 Git pre-push hook can able to execute via a Terminal but not from the IntelliJ IDEA. Git预推钩可以通过终端执行,但不能从IntelliJ IDEA执行。

I have posted the Version Control console: 我发布了版本控制台: 在此输入图像描述 And Its saying JAVA_HOME is not set. 它说JAVA_HOME没有设定。

Used Versions 使用版本

Java : 1.8.0_211
IntelliJ IDEA : IntelliJ IDEA 2019.2 EAP (Ultimate Edition), Build #IU-192.4787.16
Ubuntu : 18.04
Git : 2.17.1

Git pre-push hook script Git预推钩脚本

source ~/.bash_profile
remote="$1"
url="$2"
echo “Running Tests”
pwd
./gradlew test
exit $?

I am not getting the where is a problem exactly and How can I solve this issue ? 我不知道问题究竟在哪里,我该如何解决这个问题?

The issue is that there is no JAVA_HOME variable defined in the environment the hook is run in. The environment is inherited from the parent process, so depending on how and when IntelliJ is started, its environemnt 问题是在运行钩子的环境中没有定义JAVA_HOME变量。环境是从父进程继承的,因此取决于IntelliJ的启动方式和时间,它的环境

The easiest way to fix the issue is to define JAVA_HOME in the hook itself (or maybe in .bash_profile), eg by adding export JAVA_HOME=<PATH to your Java Home> in it. 解决问题的最简单方法是在钩子本身(或者可能在.bash_profile中)定义JAVA_HOME,例如通过向其中添加export JAVA_HOME=<PATH to your Java Home> This way variable will be set during hook execution and gradlew will not fail. 这种方式变量将在钩子执行期间设置,并且gradlew不会失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM