Java jenkins 在这个环境中没有提供编译器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23213038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 21:21:53  来源:igfitidea点击:

No compiler is provided in this environment with jenkins

javamavenjenkins

提问by Ismail Sen

I'm getting this error when I try a Jenkinsbuild on a mavenproject:

当我尝试在Maven项目上构建Jenkins时出现此错误:

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

The javaand mavenplugin are installed automatically, after several research, I couldn't find a solution!

java的Maven的插件将自动安装,一些研究之后,我无法找到一个解决方案!

Does anyone have ever face this issue?

有没有人遇到过这个问题?

回答by Nicola Musatti

According to your error message you either do not have a JDKinstalled or you need to configure Jenkins's CLASSPATH to point to your JDK installation.

根据您的错误消息,您要么没有安装JDK,要么需要配置 Jenkins 的 CLASSPATH 以指向您的 JDK 安装。

回答by sadhu

Go To Jenkins -> Manage Jenkins -> Global Tool Configuration -> JDK. Provide path to the JDK under JAVA_HOME field.

转到 Jenkins -> 管理 Jenkins -> 全局工具配置 -> JDK。在 JAVA_HOME 字段下提供 JDK 的路径。

回答by Gil

First make sure the your Job in Jenkins doesn't use the "default Jdk" by going to the job: Press on Configure - > and roll to the JDK section - and make sure you have JDK configure instead of Default.

首先通过转到作业确保您在 Jenkins 中的作业不使用“默认 Jdk”:按配置 - > 并滚动到 JDK 部分 - 并确保您配置了 JDK 而不是默认。

if you don't have it - go back to Jenkins - > Manage Jenkins -> Configure System - > Jdk and map your Jdk Root for Jenkins.

如果你没有它 - 回到 Jenkins -> 管理 Jenkins -> 配置系统 -> Jdk 并为 Jenkins 映射你的 Jdk 根。

when you finish that - go back and choose your map JDK - and everything will work.

完成后 - 返回并选择您的地图 JDK - 一切都会正常进行。

回答by Shubham Jain

Go To Jenkins -> Manage Jenkins -> Global Tool Configuration.

转到 Jenkins -> 管理 Jenkins -> 全局工具配置。

Now click on "JDK installations.." under JDK

现在点击JDK下的“JDK安装..”

Uncheck Install automatically

取消勾选自动安装

Provide path to the JDK under JAVA_HOME field.

在 JAVA_HOME 字段下提供 JDK 的路径。

Refer:-

参考:-

enter image description here

在此处输入图片说明

回答by Hamed Aziz

Just give the JDK path in Jenkins Global Tool configurations, i.e the path where we have kept the jdk file in the di

在Jenkins Global Tool配置中给出JDK路径即可,即我们在di中保存jdk文件的路径

回答by Nital

May be this issue is already resolved by now. But I had the same issue recently and I have the following settings in my Jenkins. This happened in my Windows 10Jenkinsinstallation.

可能这个问题现在已经解决了。但我最近遇到了同样的问题,我的Jenkins. 这发生在我的Windows 10Jenkins安装中。

  1. Installed JDKat C:\Java\Jdk8and made JAVA_HOMEpoint to this location. Also make sure that PATH env variable has %JAVA_HOME%\bin.
  2. Installed JRE(which comes bundled with Oracle JDKinstallation) at C:\Program Files\Java\JRE.
  3. Jenkins -> Manage Jenkins -> Configure System enter image description here

  4. Jenkins -> Manage Jenkins -> Global Tool Configuration enter image description here

  1. 安装JDKC:\Java\Jdk8JAVA_HOME指向此位置。还要确保 PATH 环境变量具有 %JAVA_HOME%\bin。
  2. 安装JRE(与Oracle JDK安装捆绑在一起)在C:\Program Files\Java\JRE.
  3. Jenkins -> 管理 Jenkins -> 配置系统 在此处输入图片说明

  4. Jenkins -> 管理 Jenkins -> 全局工具配置 在此处输入图片说明

# javac -version

# javac -version

javac 1.8.0_201

# java -version

# java -version

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

# mvn -v

# mvn -v

Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T14:41:47-04:00)
Maven home: C:\apache-maven-3.6.0\bin\..
Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: C:\Java\jdk8\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

I believe the change that fixed the problem was the addition of env variables under Manage Jenkins -> Configure System.

我相信解决问题的更改是在 .env 文件下添加了 env 变量Manage Jenkins -> Configure System

回答by SunilThorat

IF you don't want to add anythig in Global tools Configuration, add new environment variable java.homein the Jenkins slave configuration as maven detects java.homeand not JAVA_HOME.

如果您不想在全局工具配置中添加任何内容java.home,请在 Jenkins 从配置中添加新的环境变量,因为 maven 检测到java.home而不是JAVA_HOME.

java.home---> C:\Java\jdk1.8.0_181\jre

java.home---> C:\Java\jdk1.8.0_181\jre

enter image description here

在此处输入图片说明