Problems with gcloud command

davorpadovan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 1, 2018

bitbucket-pipelines.yml

image: node:8.9.4

pipelines:
default:
- step:
caches:
- node
script:
# SETUP AND TESTS
- ./test.sh

# BUILD APPLICATION
- ember build --environment=production

# DEPLOY APPLICATION
- cd dist && gcloud app deploy app.yaml -q --version production

test.sh

# INSTALL GOOGLE CLOUD SDK
curl -s -o /tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-191.0.0-linux-x86_64.tar.gz
tar -xzf /tmp/google-cloud-sdk.tar.gz -C /tmp/
/tmp/google-cloud-sdk/install.sh -q
source /tmp/google-cloud-sdk/path.bash.inc

# SETUP GOOGLE CLOUD SDK
echo $GCLOUD_SERVICE_KEY | base64 --decode > /tmp/gcloud-service-key.json
gcloud auth activate-service-account --key-file /tmp/gcloud-service-key.json
gcloud config set project cmg-frontend

# INSTALL REQUIREMENTS FOR BUILDING
npm install -g ember-cli

# INSTALL REQUIREMENTS FOR TESTING
npm install phantomjs-prebuilt

# INSTALL REQUIREMENTS FOR APP
npm install

# RUN TESTS
ember test

 I get this error:

+ cd dist && gcloud app deploy app.yaml -q --version production
bash: gcloud: command not found

But gcloud command works fine inside test.sh (successful auth and project config).

What am I missing?

Thanks!

1 answer

1 accepted

0 votes
Answer accepted
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 5, 2018

This is probably because you've installed the gcloud command into your base directory on your build. When you change directories, bash doesn't know where to find gcloud.

You can fix this by running this command in your build.

export PATH="$BITBUCKET_CLONE_DIR:$PATH"

You can learn more about PATH here: http://www.linfo.org/path_env_var.html 

The BITBUCKET_CLONE_DIR comes from here: https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events