Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Hi i tried to exxecute 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 

          - bash ./gradlew bake -Penv=test -PisRelease=false --info --stacktrace

 it give the error 

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

 

what is the issue in this case? 

1 answer

1 accepted

2 votes
Answer accepted
Graham Gatus Atlassian Team Aug 30, 2018

Hi @Mahmoud

I can see you've attempted to add the 'openjdk:8' docker image as a service. Services are designed to provide additional databases, webservices etc as part of your build, and not provide CLI tools (the exception is the pipelines built in 'docker' service, which in addition to providing a docker daemon, also makes the docker CLI available by mounting in a volume containing the docker CLI  - see https://confluence.atlassian.com/bitbucket/run-docker-commands-in-bitbucket-pipelines-879254331.html). 

The pipelines default image already provides Java 1.8.0_151, so if you want to continue using this, you can re-write your first step to be:

    - step:
name: Build And Test
script:
- bash ./gradlew clean build
- bash ./gradlew test

In your second step, you will need to either:

- Use a custom docker image that has both gcloud tools and the jdk, or

- Use the default pipelines image, and install the gcloud CLI manually

The following is an example step which has docker as a service, jdk and gcloud CLI, where the google cloud CLI is installed as part of the build:

step: 
services: 
docker 
nameBuild And Test 
script: 
# Install gcloud CLI 
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" 
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list 
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - 
sudo apt-get update && sudo apt-get install -y google-cloud-sdk 
gcloud --version 
java -version 
docker --version

Instructions for installing the gcloud CLI can be found at https://cloud.google.com/sdk/docs/downloads-apt-get

Cheers

Graham

Thanks @Graham Gatus for clarifying this to me. I've took the second option and it works now, Many thanks :) 

Like Mohd Farid Mansoori likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,926 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you