JAVA_HOME is not set and no 'java' command could be found in your PATH. bitbucket pipeline

Viewed 53246

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.

1 Answers

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.

Related