Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA_HOME is not defined correctly (only from jenkins)

Tags:

java

jenkins

ant

Trying to setup jenkins but my builds fails with:

$ ant test
Error: JAVA_HOME is not defined correctly.
  We cannot execute /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
Build step 'Invoke Ant' marked build as failure

If I manually run "ant test" on the machine it works just fine and the JAVA_HOME is set to the exact same value. Any idea why it fails when jenkins try to run it ? Are there any more environment variabled involved ( I could not see any though ) ?

like image 583
Zitrax Avatar asked Apr 16 '13 07:04

Zitrax


1 Answers

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

like image 152
Anil Avatar answered Oct 10 '22 20:10

Anil