Java executable not found when running sonar scanner in a slave Jenkins node

as the title says I’m having trouble running the sonar scanner on a distributed jenkins builder node.
The error I got is “Could not find ‘java’ executable in JAVA_HOME or PATH.”
but I developed a custom container already containing Java JDK 11, checked PATH and JAVA_HOME variables and seems to be correctly configured.
java -version commands returns
openjdk version “” 2022-02-08
OpenJDK Runtime Environment 18.9 (build
OpenJDK 64-Bit Server VM 18.9 (build, mixed mode, sharing).
Also Jenkins seems to be able to correctly connect and he requires java in path and home.

My current running version is
Jenkins 2.332.1
SonarScanner is installed on master and slave nodes using sonar plugin for Jenkins at version, install automatically flag is checked.
This shouldn’t be a pipeline error since the master node works just as expected and I don’t see connection issue, simply java errors.
I already tried uninstalling java from the node and reinstalling it manually, adding to the path and java home the correct location for the package but still does not seems to work

I managed to fix it manually setting the path inside the sonar scanner script

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.