TD jones
TD jones

Reputation: 21

Jenkins Maven project no compiler is provided in this environment

I've been using Jenkins and Maven to run some of my automation jobs but recently I noticed that console log keeps displaying the same error during clean install process. I tried updating JAVA_HOME and other all sorts of things online but none of it worked. Even though the job completes and passed the build would just fail be cause of the error here:

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

Upvotes: 2

Views: 5065

Answers (2)

J E Carter II
J E Carter II

Reputation: 1506

At least two other sources indicate that, with remote agents, you need to create an environment variable in the node configuration for java.home pointing to the JAVA_HOME directory (not simply %JAVA_HOME% or similar).

Navigate to: Jenkins > Manage Jenkins > Manage Nodes and click the configure icon next to your remote Node. From there, scroll down to Node Properties, tick the box for Environment Variables and define java.home for name and the path to your JDK for the value, e.g. c:\Program Files\Java\jdk1.8.0_181

This was what I eventually needed to do, even after all system environment variables were found to be correct on the build agent server and both java -version and javac -version were correctly reporting.

I realize the OP doesn't specify Master or Remote, but hopefully this is helpful to someone who stumbles upon this Q & A.

This source provided the first clue but no explanation: https://www.pgs-soft.com/blog/oops-jenkins-slave-maven-not-working/

I'm unable to track down the other mention of this fix I found while googling.

Upvotes: 1

Seeker
Seeker

Reputation: 957

looks like jenkins is not able to pick jdk. Please check your JAVA_HOME is setup and pointing to JDK.

you can also try setting JAVA_HOME as below from jenkins UI:

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

Upvotes: 0

Related Questions