【问题标题】:Jenkins Maven project no compiler is provided in this environmentJenkins Maven 项目在这个环境中没有提供编译器
【发布时间】:2016-11-23 01:42:45
【问题描述】:

我一直在使用 Jenkins 和 Maven 来运行我的一些自动化作业,但最近我注意到控制台日志在全新安装过程中一直显示相同的错误。我尝试在网上更新 JAVA_HOME 和其他各种东西,但都没有奏效。即使作业完成并通过了构建,也会因为这里的错误而失败:

Executing Maven:  -B -f D:\jenkins\workspace\DummyTesting\pom.xml clean install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building automation 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ automation ---
[INFO] Deleting D:\jenkins\workspace\DummyTesting\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @     automation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\jenkins\workspace    \DummyTesting\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ automation ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ automation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ automation ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 51 source files to D:\jenkins\workspace\DummyTesting\target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.679 s
[INFO] Finished at: 2016-11-22T15:17:57+08:00
[INFO] Final Memory: 9M/23M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project automation: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

【问题讨论】:

  • 你能显示这个作业的 JAVA_HOME 配置吗? (你可以在构建的环境变量中看到它)
  • 查看消息也许您在 JRE 而不是 JDK 上运行?。 JRE不来会编译工具,你要设置一个JDK为JAVA_HOME
  • 这是我在其中一个节点 C:\Program Files (x86)\Java\jdk1.8.0_91 上为 JAVA_HOME 配置的
  • 很抱歉让我这么久才回复,但如果有人能提供帮助,我将不胜感激

标签: java maven jenkins


【解决方案1】:

至少有两个其他来源表明,对于远程代理,您需要为java.home 创建一个环境变量在节点配置中 指向JAVA_HOME 目录(不仅仅是%JAVA_HOME% 或类似的)。

导航至:Jenkins > Manage Jenkins > Manage Nodes 并单击远程节点旁边的配置图标。从那里,向下滚动到节点属性,勾选 Environment Variables 框并定义 java.home 作为名称和 JDK 的路径作为值,例如c:\Program Files\Java\jdk1.8.0_181

这是我最终需要做的,即使在构建代理服务器上发现所有系统环境变量都正确并且java -versionjavac -version 都正确报告之后。

我意识到 OP 没有指定 Master 或 Remote,但希望这对偶然发现此问答的人有所帮助。

此来源提供了第一个线索但没有解释:https://www.pgs-soft.com/blog/oops-jenkins-slave-maven-not-working/

我无法找到在谷歌搜索时发现的有关此修复的其他提及。

【讨论】:

    【解决方案2】:

    看起来 jenkins 无法选择 jdk。请检查您的 JAVA_HOME 是否已设置并指向 JDK。

    您也可以尝试在 jenkins UI 中设置 JAVA_HOME,如下所示:

    Go To Jenkins -> Manage Jenkins -> Configure System -> JDK. Configure path to the JDK under JAVA_HOME field.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-04
      • 2015-11-03
      • 2019-08-16
      • 2021-11-26
      • 2014-02-01
      • 2014-05-08
      相关资源
      最近更新 更多