Jenkins slave unable to figure out java version
Asked Answered
E

4

6
[03/21/16 16:09:39] [SSH] Opening SSH connection to 172.18.73.53:22.
[03/21/16 16:09:40] [SSH] Authentication successful.
[03/21/16 16:09:40] [SSH] The remote users environment is:
[03/21/16 16:09:40] [SSH] Checking java version of java
Couldn't figure out the Java version of java

[03/21/16 16:09:41] [SSH] Checking java version of /usr/bin/java
Couldn't figure out the Java version of /usr/bin/java
[03/21/16 16:09:41] [SSH] Checking java version of      /usr/java/default/bin/java
Couldn't figure out the Java version of /usr/java/default/bin/java

I am getting the above error on launching the slave

Einstein answered 21/3, 2016 at 9:7 Comment(0)
P
5

It is trying to execute "/usr/bin/java -version" at first, then "/usr/java/default/bin/java -version" but both commands seem to be failing. This might be caused by wrong tool location on slave. You should first figure out the java executable location on your slave:

which java

Then, under slave configuration on Jenkins, enable "Tool Locations" checkbox and add your correct Java path there and save.

Painter answered 21/3, 2016 at 9:40 Comment(1)
I solved this by adding java path not to 'Tool Locations', but 'Advanced-JavaPath'Chemist
A
4

Check to see which java is on Slave

# which java

Then copy the java path and add it under Advanced configuration of Launch Agents via ssh block.

Manage Jenkins > Manage Nodes and Clouds > Configure node > Advanced section under Launch Agents via ssh block > "update Java path in there"

Agora answered 18/3, 2021 at 18:25 Comment(0)
S
0

As Doruk said

It is trying to execute "/usr/bin/java -version" at first, then "/usr/java/default/bin/java -version" but both commands seem to be failing.

However I couldn't find Java under the "Tool locations" option, so the solution that worked for me is to create a link from the java which you do run to the location Jenkins wants.

JAVA_IN=$(which java)
ln -s $JAVA_IN /usr/bin/java
Seeley answered 14/1, 2020 at 16:42 Comment(0)
S
0

A simple solution is to install JDK17 just for Jenkins:

  1. Download: https://adoptium.net/temurin/releases/?arch=any&os=linux&version=17
  2. Copy tgz to your jenkins node (agent) root e.g. to /var/jenkins.
  3. Unpack tgz.
  4. Rename unpacked directory from "jdk-..." to "jdk".
  5. Check version: /var/jenkins/jdk/bin/java -version

This steps should work for any Linux agent.

Sadfaced answered 28/3 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.