Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab CI: Unable to set JAVA_HOME

I am running git-lab server with Ubuntu 14 I am trying to compile a build on git-lab Ci but for some reasons I keep getting the same error over and over again:

ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-7-openjdk-amd64/jre Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

No matter how I change the path of JAVA_HOME it is always the same results. I have 4 folders inside the JVM folder:

java-8-oracle
java-7-openjdk-amd64
java-1.7.0-openjdk-amd64
default-java

But again no matter which directory I set the path to it is always the same result.

Here is my .gitlab-ci.yml file:

 before_script:
- export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
- export ANDROID_HOME="/opt/android-sdk"
- chmod +x gradlew

dev:  
  script:
  - ./gradlew assembleDebug

What could be the cause of this error?

like image 395
user6006748 Avatar asked May 09 '16 10:05

user6006748


2 Answers

Try to change your .gitlab-ci.yml to this:

before_script:  
  - export ANDROID_HOME="/opt/android-sdk"
  - export JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-amd64"
  - chmod +x gradlew

dev:  
  script:
    - ./gradlew assembleDebug
like image 55
Mauker Avatar answered Sep 20 '22 14:09

Mauker


You can try removing chmod +x gradlew from before_script and move it to the main script:

before_script:
- export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
- export ANDROID_HOME="/opt/android-sdk"

dev:  
  script:
  - chmod +x ./gradlew
  - ./gradlew assembleDebug

Reference: https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/#comment-4440925341

like image 21
Paula Avatar answered Sep 23 '22 14:09

Paula