JAVA_HOME is not defined correctly (only from jenkins)

Set JAVA_HOME in your Jenkins system config in Jenkins 2.107.1.

open your jenkins, e.g. http://192.168.1.12:9090, then add /configure to the url, that is http://192.168.1.12:9090/configure, then you can find like next:

enter image description here


For others, I had to add the PATH /usr/bin/ to my PATH variable within Jenkins. (Find your correct path using which java).

Jenkins > Manage Jenkins > Configure System

Add an Environment Variable >>

e.g:

Name: PATH
Value: /usr/local/bin/:/usr/bin/

Screenshot

enter image description here


The problem was this, I had forgot to check the box "Restrict where this project can be run" in the project configuration. Thus the testing tried to execute on "master" where JAVA_HOME was not the same as expected on the build executor I intended to run it on. Thus where I tested and where it actually ran was different machines.

Tags:

Java

Ant

Jenkins