在编译代码时,在Jenkins中获得以下错误:
Error: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:\Users\admin\.jenkins\tools\hudson.model.JDK"
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
在Environment变量中,我将JAVA_HOME设置为:
C:\Program Files\Java\jdk1.8.0_45
在Jenkins的Build部分下,我将目标定为“编译” 用于“调用顶级Maven目标”。
请提供宝贵的建议。
答案 0 :(得分:0)
尝试在Environment变量的“Path”中添加此命令 C:\ ProgramData \甲骨文\爪哇\ javapath;%JAVA_HOME%\ bin中
答案 1 :(得分:0)
It appears that Jenkins when installed as a service over-rides the set JAVA_HOME system environment variable and sets itself to JRE that came with Jenkins installation. So all Java Builds fail, as this requires JDK
The solution that worked for us is, we had to configure JAVA_HOME environment variable in Manage Jenkins > Configure System > Global Properties