gcloud command not found with ssh-run

Teera Surawat
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!
June 4, 2023

I create bitbucket pipelines for ssh to my server and run sh script that use `gcloud` command but I got message:

`/home/...../deploy-script.sh: line 7: gcloud: command not found`

In my server I install google-cloud sdk already, when I ssh to my server (not from bitbucket pipelines) I can use `gcloud` command.

 

This is some of bitbucket pipelines

 

image: atlassian/default-image:2

definitions:

  services:

    docker:

      memory: 3072

pipelines:

  branches:

    master:

      - step:

          name: Deploy to GCP VM

          script:

            - echo "Start deploy to GCP VM"

            - pipe: atlassian/ssh-run:0.4.2

              variables:

                SSH_USER: $SSH_USER

                SERVER: $SSH_HOST

                COMMAND: '/home/...../deploy-script.sh'

 

This is some of deploy-script.sh

 

#!/bin/bash

 

work_directory="$(dirname "$(realpath "$0")")"

cd $work_directory

echo "Logging in to GCP GCR....."

docker login -u oauth2accesstoken -p "$(gcloud auth print-access-token)" https://asia.gcr.io

 

How i can fix this?

Sorry for my bad english.

1 answer

1 vote
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2023

Hi @Teera Surawat 

The PATH variable can be different based on the user and login type (interactive or not). 

Try first printing the PATH variable and see if `gcloud` command is in the path.

To resolve this issue, you can either look into the various ~/*profile and ~/*rc files, to check which one is actually read during your login, or just update the PATH during runtime.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events