Question about JDK and Maven through Jenkins

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about JDK and Maven through Jenkins

marafado88
Hello,

Its my first time using jenkins and I am still learning how it works, so if you see some unnecessary info dont be mad lol.

I am using a CentOS 7, and I have installed JAVA(openjdk version "1.8.0_161") and MAVEN(Apache Maven 3.5.2).

Now, I have imported the repo from this tutorial(https://www.youtube.com/watch?v=s73nhwYBtzE), to my new account at bitbucket.

As plugins I have install several that to me was looking necessary for that tutorial: https://pastebin.com/zU19r8PV

Then I created a new Pipeline at Jenkins with the right login for my bitbucket repo git.

Then tried to 'Build Now' but it fails at Compile Stage:

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jenkins-example ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/jenkins-example/target/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] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.767 s
[INFO] Finished at: 2018-02-13T16:45:06Z
[INFO] Final Memory: 9M/102M
[INFO] ------------------------------------------------------------------------
[INFO] [jenkins-event-spy] Generated /var/lib/jenkins/workspace/jenkins-example@tmp/withMavenabb6bf9d/maven-spy-20180213-164505-820349381958923572055.log
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jenkins-example: 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

Now a side of having JAVA and MAVIN installed in CentOS, I was trying to use JDK from java.sun.com(with an account from Oracle) and Maven from Apache through Jenkins webservice in Global Tool Configuration but still I have the same output errors.

Also at Maven I add the name of maven_3_5_2 and change it in jenkinsfile in that repo that I have cloned to my account.

This is a noob question, but I need some guidence here =|

Thanks!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d2ce894c-c280-4976-94cb-13a213c56acc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about JDK and Maven through Jenkins

Cyrille Le Clerc
Hello Fábio,

Could you have installed a JRE instead of installing a JDK on your build agent?

Can you please:
  • Add the following instruction in your Jenkinsfile just before the invocation  sh "mvn..." (1):
    • sh "which java"
    • sh "which javac"
  • Re run the pipeline
  • Share the Jenkinsfile you use?
  • share the build logs with us
Note that if "which javac" fails then your problem is that you have installed a JRE when Maven requires a JDK. 
  • A solution is to install a jdk on CentOS "sudo yum install java-1.8.0-openjdk-devel". See http://openjdk.java.net/install/
  • An alternative is to install a JDK through Jenkins Tool Installer
Cyrille

(1) sample
pipeline {
    agent any
    stages {
     stage ("Build") {
        steps {
        git "https://github.com/cyrille-leclerc/my-jar.git"
        withMaven(maven:"maven-3.5.2") {
            writeFile file: '.archive-jenkins-maven-event-spy-logs', text: ''
            sh "which java"
            sh "which javac"
            sh "mvn clean deploy"
         }
        }
    }       
    }
}

On Wednesday, February 14, 2018 at 7:42:01 PM UTC+1, Fábio Cabrita wrote:
Hello,

Its my first time using jenkins and I am still learning how it works, so if you see some unnecessary info dont be mad lol.

I am using a CentOS 7, and I have installed JAVA(openjdk version "1.8.0_161") and MAVEN(Apache Maven 3.5.2).

Now, I have imported the repo from this tutorial(<a href="https://www.youtube.com/watch?v=s73nhwYBtzE" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.youtube.com/watch?v\x3ds73nhwYBtzE&#39;;return true;" onclick="this.href=&#39;https://www.youtube.com/watch?v\x3ds73nhwYBtzE&#39;;return true;">https://www.youtube.com/watch?v=s73nhwYBtzE), to my new account at bitbucket.

As plugins I have install several that to me was looking necessary for that tutorial: <a href="https://pastebin.com/zU19r8PV" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fpastebin.com%2FzU19r8PV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGC1_USsom-wbhpqB43yu2_aOAwbQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fpastebin.com%2FzU19r8PV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGC1_USsom-wbhpqB43yu2_aOAwbQ&#39;;return true;">https://pastebin.com/zU19r8PV

Then I created a new Pipeline at Jenkins with the right login for my bitbucket repo git.

Then tried to 'Build Now' but it fails at Compile Stage:

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jenkins-example ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/jenkins-example/target/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] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.767 s
[INFO] Finished at: 2018-02-13T16:45:06Z
[INFO] Final Memory: 9M/102M
[INFO] ------------------------------------------------------------------------
[INFO] [jenkins-event-spy] Generated /var/lib/jenkins/workspace/jenkins-example@tmp/withMavenabb6bf9d/maven-spy-20180213-164505-820349381958923572055.log
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jenkins-example: 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] <a href="http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FMAVEN%2FMojoFailureException\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGaJwCeoibCpQ86aiPLWDPHJDTRFg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FMAVEN%2FMojoFailureException\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGaJwCeoibCpQ86aiPLWDPHJDTRFg&#39;;return true;">http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Now a side of having JAVA and MAVIN installed in CentOS, I was trying to use JDK from <a href="http://java.sun.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjava.sun.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGedajitVHqUilFoS50eE1IlQYCMg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjava.sun.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGedajitVHqUilFoS50eE1IlQYCMg&#39;;return true;">java.sun.com(with an account from Oracle) and Maven from Apache through Jenkins webservice in Global Tool Configuration but still I have the same output errors.

Also at Maven I add the name of maven_3_5_2 and change it in jenkinsfile in that repo that I have cloned to my account.

This is a noob question, but I need some guidence here =|

Thanks!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5ddae108-8576-46dc-9e3d-b19eda55de38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about JDK and Maven through Jenkins

marafado88
In reply to this post by marafado88
Using mvn -X to get an extented debug I got:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jenkins-example: Compilation failure

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

[ERROR] -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jenkins-example: Compilation failure

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




quarta-feira, 14 de Fevereiro de 2018 às 18:42:01 UTC, Fábio Cabrita escreveu:
Hello,

Its my first time using jenkins and I am still learning how it works, so if you see some unnecessary info dont be mad lol.

I am using a CentOS 7, and I have installed JAVA(openjdk version "1.8.0_161") and MAVEN(Apache Maven 3.5.2).

Now, I have imported the repo from this tutorial(<a href="https://www.youtube.com/watch?v=s73nhwYBtzE" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.youtube.com/watch?v\x3ds73nhwYBtzE&#39;;return true;" onclick="this.href=&#39;https://www.youtube.com/watch?v\x3ds73nhwYBtzE&#39;;return true;">https://www.youtube.com/watch?v=s73nhwYBtzE), to my new account at bitbucket.

As plugins I have install several that to me was looking necessary for that tutorial: <a href="https://pastebin.com/zU19r8PV" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fpastebin.com%2FzU19r8PV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGC1_USsom-wbhpqB43yu2_aOAwbQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fpastebin.com%2FzU19r8PV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGC1_USsom-wbhpqB43yu2_aOAwbQ&#39;;return true;">https://pastebin.com/zU19r8PV

Then I created a new Pipeline at Jenkins with the right login for my bitbucket repo git.

Then tried to 'Build Now' but it fails at Compile Stage:

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jenkins-example ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/jenkins-example/target/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] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.767 s
[INFO] Finished at: 2018-02-13T16:45:06Z
[INFO] Final Memory: 9M/102M
[INFO] ------------------------------------------------------------------------
[INFO] [jenkins-event-spy] Generated /var/lib/jenkins/workspace/jenkins-example@tmp/withMavenabb6bf9d/maven-spy-20180213-164505-820349381958923572055.log
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jenkins-example: 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] <a href="http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FMAVEN%2FMojoFailureException\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGaJwCeoibCpQ86aiPLWDPHJDTRFg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FMAVEN%2FMojoFailureException\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGaJwCeoibCpQ86aiPLWDPHJDTRFg&#39;;return true;">http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Now a side of having JAVA and MAVIN installed in CentOS, I was trying to use JDK from <a href="http://java.sun.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjava.sun.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGedajitVHqUilFoS50eE1IlQYCMg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjava.sun.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGedajitVHqUilFoS50eE1IlQYCMg&#39;;return true;">java.sun.com(with an account from Oracle) and Maven from Apache through Jenkins webservice in Global Tool Configuration but still I have the same output errors.

Also at Maven I add the name of maven_3_5_2 and change it in jenkinsfile in that repo that I have cloned to my account.

This is a noob question, but I need some guidence here =|

Thanks!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b66813b4-7f34-4225-b7ba-b1ce461de3ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about JDK and Maven through Jenkins

Victor Martinez
if you run mvn -V -v . then you will see what's the java version and some other mvn environmental details which are used within maven, most likely it's not using the JDK but the JRE for some reason, please review how that particular JDK setup was made. 

Cheers

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1b745540-5251-46c4-b00f-937ba1896138%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about JDK and Maven through Jenkins

Cyrille Le Clerc
In reply to this post by marafado88
Please try "which java && which javac" doing an ssh on this build agent.

I suspect that "javac" is missing and that would explain "No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?"



On Fri, Feb 16, 2018 at 4:36 PM, Fábio Cabrita <[hidden email]> wrote:
Using mvn -X to get an extented debug I got:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jenkins-example: Compilation failure

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

[ERROR] -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jenkins-example: Compilation failure

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




quarta-feira, 14 de Fevereiro de 2018 às 18:42:01 UTC, Fábio Cabrita escreveu:
Hello,

Its my first time using jenkins and I am still learning how it works, so if you see some unnecessary info dont be mad lol.

I am using a CentOS 7, and I have installed JAVA(openjdk version "1.8.0_161") and MAVEN(Apache Maven 3.5.2).

Now, I have imported the repo from this tutorial(https://www.youtube.com/watch?v=s73nhwYBtzE), to my new account at bitbucket.

As plugins I have install several that to me was looking necessary for that tutorial: https://pastebin.com/zU19r8PV

Then I created a new Pipeline at Jenkins with the right login for my bitbucket repo git.

Then tried to 'Build Now' but it fails at Compile Stage:

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jenkins-example ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/jenkins-example/target/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] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.767 s
[INFO] Finished at: 2018-02-13T16:45:06Z
[INFO] Final Memory: 9M/102M
[INFO] ------------------------------------------------------------------------
[INFO] [jenkins-event-spy] Generated /var/lib/jenkins/workspace/jenkins-example@tmp/withMavenabb6bf9d/maven-spy-20180213-164505-820349381958923572055.log
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jenkins-example: 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:

Now a side of having JAVA and MAVIN installed in CentOS, I was trying to use JDK from java.sun.com(with an account from Oracle) and Maven from Apache through Jenkins webservice in Global Tool Configuration but still I have the same output errors.

Also at Maven I add the name of maven_3_5_2 and change it in jenkinsfile in that repo that I have cloned to my account.

This is a noob question, but I need some guidence here =|

Thanks!

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/PDdb0_8Lq7Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b66813b4-7f34-4225-b7ba-b1ce461de3ee%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Cyrille Le Clerc
Director of Product Management CloudBees, Inc.

CloudBees-Logo.png


M: +33-6.61.33.69.86
E: [hidden email]

Skype: cyrille.leclerc



--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADA0CVy1tDopJqaTe8hCKay_7gsn%2BKk6nZ%3DBBLDg%2BZMOqU_juw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about JDK and Maven through Jenkins

marafado88
In reply to this post by marafado88
Here are both command paths:

root@jenkins-server /h/jenkins> which java
/bin/java
root@jenkins
-server /h/jenkins> which javac
/bin/javac

While checking mvn, I notice that Java home is set to JRE instead of JDK:


[jenkins@jenkins-server ~]$ mvn --version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T08:58:13+01:00)
Maven home: /usr/local/maven
Java version: 1.8.0_161, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name
: "linux", version: "3.10.0-693.17.1.el7.x86_64", arch: "amd64", family: "unix"

Checking Java version:

[jenkins@jenkins-server ~]$ java -version
openjdk version
"1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

In this system I have several Java's versions installed in this system:

[root@jenkins-server ~]# sudo update-alternatives --config java

There are 2 programs which provide 'java'.

 
Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java)
   
2           java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/jre/bin/java)

[root@jenkins-server ~]# sudo update-alternatives --config javac

There is 1 program that provides 'javac'.

Selection Command
-----------------------------------------------
*+ 1 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/bin/javac)

But dont know how to set mavens to use java JDK.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4b27f009-70bd-4f94-89e4-63178e24195a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about JDK and Maven through Jenkins

Cyrille Le Clerc
Can you install "java-1.8.0-openjdk-devel" on your server so that javac-1.8 is also installed?

I suspect that Jenkins and Maven get tricked by the fact that your default "java" installation doesn't have a "javac" compiler.

If you cannot install "java-1.8.0-openjdk-devel", I strongly recommend to rely on Jenkins' capability to install a JDK:
  • In Jenkins UI, with Jenkins administrator privileges, navigate to "Manage Jenkins / Global Tools Installer"
  • In the "JDK" section, click on "JDK Installations..." then "Add JDK"
    • Choose the name "1.8"
    • Select a JDK 8 version (e.g. "Java SE Development Kit 8u162")
    • Enter oracle.com credentials 
  • Update your pipeline script and add "jdk: '1.8' "to your "withMaven"() step: "withMaven(jdk: 1.8', ...){...}"
Cyrille

On Monday, February 19, 2018 at 11:29:09 AM UTC+1, Fábio Cabrita wrote:
Here are both command paths:

root@jenkins-server /h/jenkins> which java
/bin/java
root@jenkins
-server /h/jenkins> which javac
/bin/javac

While checking mvn, I notice that Java home is set to JRE instead of JDK:


[jenkins@jenkins-server ~]$ mvn --version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T08:58:13+01:00)
Maven home: /usr/local/maven
Java version: 1.8.0_161, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name
: "linux", version: "3.10.0-693.17.1.el7.x86_64", arch: "amd64", family: "unix"

Checking Java version:

[jenkins@jenkins-server ~]$ java -version
openjdk version
"1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

In this system I have several Java's versions installed in this system:

[root@jenkins-server ~]# sudo update-alternatives --config java

There are 2 programs which provide 'java'.

 
Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java)
   
2           java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/jre/bin/java)

[root@jenkins-server ~]# sudo update-alternatives --config javac

There is 1 program that provides 'javac'.

Selection Command
-----------------------------------------------
*+ 1 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/bin/javac)

But dont know how to set mavens to use java JDK.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/89ba8611-110c-476b-97d4-feb337ed8464%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about JDK and Maven through Jenkins

marafado88
Thats the strange part because I have javac installed in this system.

Now I have added a new field for jdk in jenkinsfile(as well as in Global Tools Installer) and its working:

    tools {
        jdk
'java_9'
    }

Thanks for the help Cyrille Le Clerc!

segunda-feira, 19 de Fevereiro de 2018 às 13:54:39 UTC, Cyrille Le Clerc escreveu:
Can you install "java-1.8.0-openjdk-devel" on your server so that javac-1.8 is also installed?

I suspect that Jenkins and Maven get tricked by the fact that your default "java" installation doesn't have a "javac" compiler.

If you cannot install "java-1.8.0-openjdk-devel", I strongly recommend to rely on Jenkins' capability to install a JDK:
  • In Jenkins UI, with Jenkins administrator privileges, navigate to "Manage Jenkins / Global Tools Installer"
  • In the "JDK" section, click on "JDK Installations..." then "Add JDK"
    • Choose the name "1.8"
    • Select a JDK 8 version (e.g. "Java SE Development Kit 8u162")
    • Enter <a href="http://oracle.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Foracle.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_5cbKDxzZHMFG-5zhjxZJ93TUYg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Foracle.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_5cbKDxzZHMFG-5zhjxZJ93TUYg&#39;;return true;">oracle.com credentials 
  • Update your pipeline script and add "jdk: '1.8' "to your "withMaven"() step: "withMaven(jdk: 1.8', ...){...}"
Cyrille

On Monday, February 19, 2018 at 11:29:09 AM UTC+1, Fábio Cabrita wrote:
Here are both command paths:

root@jenkins-server /h/jenkins> which java
/bin/java
root@jenkins
-server /h/jenkins> which javac
/bin/javac

While checking mvn, I notice that Java home is set to JRE instead of JDK:


[jenkins@jenkins-server ~]$ mvn --version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T08:58:13+01:00)
Maven home: /usr/local/maven
Java version: 1.8.0_161, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name
: "linux", version: "3.10.0-693.17.1.el7.x86_64", arch: "amd64", family: "unix"

Checking Java version:

[jenkins@jenkins-server ~]$ java -version
openjdk version
"1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

In this system I have several Java's versions installed in this system:

[root@jenkins-server ~]# sudo update-alternatives --config java

There are 2 programs which provide 'java'.

 
Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java)
   
2           java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/jre/bin/java)

[root@jenkins-server ~]# sudo update-alternatives --config javac

There is 1 program that provides 'javac'.

Selection Command
-----------------------------------------------
*+ 1 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/bin/javac)

But dont know how to set mavens to use java JDK.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0dc56b5f-bc7f-442d-a991-dc77efaa177d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about JDK and Maven through Jenkins

santosh salunke
In reply to this post by Cyrille Le Clerc
Thanks :) 

On Monday, February 19, 2018 at 7:24:39 PM UTC+5:30, Cyrille Le Clerc wrote:
Can you install "java-1.8.0-openjdk-devel" on your server so that javac-1.8 is also installed?

I suspect that Jenkins and Maven get tricked by the fact that your default "java" installation doesn't have a "javac" compiler.

If you cannot install "java-1.8.0-openjdk-devel", I strongly recommend to rely on Jenkins' capability to install a JDK:
  • In Jenkins UI, with Jenkins administrator privileges, navigate to "Manage Jenkins / Global Tools Installer"
  • In the "JDK" section, click on "JDK Installations..." then "Add JDK"
    • Choose the name "1.8"
    • Select a JDK 8 version (e.g. "Java SE Development Kit 8u162")
    • Enter <a href="http://oracle.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Foracle.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_5cbKDxzZHMFG-5zhjxZJ93TUYg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Foracle.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_5cbKDxzZHMFG-5zhjxZJ93TUYg&#39;;return true;">oracle.com credentials 
  • Update your pipeline script and add "jdk: '1.8' "to your "withMaven"() step: "withMaven(jdk: 1.8', ...){...}"
Cyrille

On Monday, February 19, 2018 at 11:29:09 AM UTC+1, Fábio Cabrita wrote:
Here are both command paths:

root@jenkins-server /h/jenkins> which java
/bin/java
root@jenkins
-server /h/jenkins> which javac
/bin/javac

While checking mvn, I notice that Java home is set to JRE instead of JDK:


[jenkins@jenkins-server ~]$ mvn --version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T08:58:13+01:00)
Maven home: /usr/local/maven
Java version: 1.8.0_161, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name
: "linux", version: "3.10.0-693.17.1.el7.x86_64", arch: "amd64", family: "unix"

Checking Java version:

[jenkins@jenkins-server ~]$ java -version
openjdk version
"1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

In this system I have several Java's versions installed in this system:

[root@jenkins-server ~]# sudo update-alternatives --config java

There are 2 programs which provide 'java'.

 
Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java)
   
2           java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/jre/bin/java)

[root@jenkins-server ~]# sudo update-alternatives --config javac

There is 1 program that provides 'javac'.

Selection Command
-----------------------------------------------
*+ 1 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/bin/javac)

But dont know how to set mavens to use java JDK.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0fe1f578-0f56-4e09-965b-6cad1c77ce9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.