use*_*657 6 java git maven jenkins
编译代码时,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.
Run Code Online (Sandbox Code Playgroud)
在环境变量中,我将 JAVA_HOME 设置为:
C:\Program Files\Java\jdk1.8.0_45
Run Code Online (Sandbox Code Playgroud)
在 Jenkins 的“构建”部分下,我将“调用顶级 Maven 目标”的目标设置为“编译”。
请提出您的宝贵建议。
看来 Jenkins 当作为服务安装时会覆盖设置的 JAVA_HOME 系统环境变量并将其自身设置为 Jenkins 安装附带的 JRE。所以所有 Java 构建都会失败,因为这需要 JDK
\n\n对我们有用的解决方案是,我们必须在中配置 JAVA_HOME 环境变量Manage Jenkins > Configure System >\xc2\xa0Global Properties