It worked for me.
First step I setup the Java settings adding the location of the java binary


Then I changed the jenkinsfile adding the JDK option

pipeline {
     agent any 
     tools { 
          maven 'Default' 
         * jdk 'Default'* 
     }

     :

On Monday, February 19, 2018 at 11:16:33 AM UTC-3, marafado88 wrote:
>
> 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 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c7d064f8-172b-4530-b9b3-82ed4776430a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to