Hi i tried to execute a gradle command in bitbucket pipeline
definitions:
services:
java:
image: openjdk:8
pipelines:
default:
- step:
name: Build And Test
services:
- java
script:
- bash ./gradlew clean build
- bash ./gradlew test
- step:
name: configure gcloud
deployment: test
image: google/cloud-sdk:214.0.0-alpine
services:
- java
- docker
caches:
- gradle
script:
- gcloud auth configure-docker --quiet
- docker login -u _json_key -p "$GCR_JSON_KEY" https://gcr.io
- bash ./gradlew bake -Penv=test -PisRelease=false --info --stacktrace
when it tried to execute the latest task
it give the error JAVA_HOME is not set and no 'java' command could be found in your PATH.
AS you see there's a java image and it works in the first step but in the second step if failed and this is the issue.
Download Liberica JDK and on installation it will automatically set JAVA_HOME environment variable. Now you just go to Android Studio -> Project Structure -> SDK -> Point all jdk path to liberica jdk installation directory and apply. You are done. Just restart android studio and gradle command will work.
All you need to do to fix this error is edit the JAVA_HOME variable and point it to the correct directory. The JAVA_HOME environment variable must point to the root of the installation folder of a JDK.
To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.
Go to Manage Jenkins – Configure System, to the Global properties section and enable Environment variables. Add an environment variable for JAVA_HOME and fill the path with /var/jenkins_home/tools/hudson.
You had set JAVA_HOME? If not, read here
To set JAVA_HOME, do the following:
a. Right click My Computer and select Properties.
b. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.6.0_02.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With