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

gcloud projects list is always empty

HosamEmam May 5, 2020

When i am trying to access projects in my google cloud account using 

gcloud projects list

always getting the following

+ gcloud projects listListed 0 items. 

So I can't complete the steps  - and i can't set the project 

and in this step

gcloud config set project $MY_PROJECT

I got 

+ gcloud config set project #My_PROJECT Updated property [core/project].
WARNING: You do not appear to have access to project [#My_PROJECT] or it does not exist.

The following is steps in my pipeline

- step:
name: Test google auth
image: google/cloud-sdk:latest
script:
- echo $KEY_FILE | base64 --decode --ignore-garbage > ~/google-key.json
- gcloud auth activate-service-account --key-file ~/google-key.json
- gcloud projects list
- gcloud config set project $MY_PROJECT
- gcloud container clusters get-credentials $MY_CLUSTER --region $REGION
services:
- docker

- Is there any missing steps? or prerequists to link bitbucket to my google account?

2 answers

1 accepted

0 votes
Answer accepted
Ahmed Yehia May 14, 2020

If you successfully activate the service account as follows:

gcloud auth activate-service-account --key-file service-account-key.json

and you can see it as the ACTIVE one after executing the following:

gcloud auth list

and still, get ZERO items

Listed 0 items.

after executing the following:

gcloud projects list

THEN

Try to add your service account as a member of your Organization beside the project and assign it a Viewer role.

0 votes
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 13, 2020

Hi @HosamEmam ,

Thank you for the feedback!

Have you encoded and configured a $KEY_FILE properly?

Encode the private key

Pipelines does not currently support line breaks in environment variables, so base-64 encode the private key by running:

LINUX

$ base64 -w 0 < google-key.json

MAC OS X
$ base64 < google-key.json
HosamEmam May 13, 2020

It is encoded well as after decoding, I tried to read the result and found it correct, i encoded using windows - as the following example

certutil -encode data.txt tmp.b64 && findstr /v /c:- tmp.b64 > data.b64

 And i tried it without encoding just plain text and the same issue

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events