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

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

ERROR: (gcloud.auth.activate-service-account)

Greetings,

I have a service account json file located in the root directory of my pipeline - still in development mode - and when I try to run the pipeline, I get the following error:

ERROR: (gcloud.auth.activate-service-account) Could not read json file /tmp/key-file.json: Expecting value: line 1 column 1 (char 0)

 

Here is my pipe:

- pipe: atlassian/google-app-engine-deploy:0.7.0

  variables:

    KEY_FILE: 'gcloud-api-key.json'

 

Not sure why it won't find it? 

 

Thanks,

Adam

2 answers

0 votes

Hello, @Adam_Woloszyn , you can recheck environment variable KEY_FILE. This should base64 encoded string , not filename. So the setting would be

KEY_FILE: $(cat gcloud-api-key.json').

This json file should contain proper base64 content and

This can be a tricky part, but we have a guide for this

https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html#UseSSHkeysinBitbucketPipelines-UsemultipleSSHkeysinyourpipeline , section "Use multiple SSH keys in your pipeline".

You can use the same approach for your key.

 

We will update the documentation to be more clear in future releases

Greetings,

I appreciate your reply, however that didn't seem to work:

bash: /opt/atlassian/pipelines/agent/tmp/bashScript4455552900426182708.sh: line 72: unexpected EOF while looking for matching `''

 

I'll keep trying different things though.

Thanks,

Adam

@Adam Woloszyn , could you provide the full log, please? I don't see json parsed here related, only bash

This solution I proposed for local testing

KEY_FILE: $(cat gcloud-api-key.json'),

but you can still refer to confluence docs I mentioned to set environment variable right in the pipeline (Deployments section, Repository Variables)

It worked with this: KEY_FILE: $(cat encoded.json)

 

But I will read the article.

Weird part is that nothing showed up in my Deployments section after using that pipe. I thought that was the point of it?

 

Thanks for the help - if you know more about the Deployment sections that'd be helpful too!

 

Thanks,

@Adam Woloszyn to answer on your question, I need to know, what exactly has not been shown up.

For example, secured variables like KEY_FILE , they are shown in Deployments section variables, but masked. And in the logs they are not shown.

@Adam Woloszyn I guess you define key file variable as path variable where encoded string lies.

This is not the base case of usage.Obtain  KEY_FILE variable (and put to the repository variable) like this:

base64 < your-service-account-file.json - you will have base64 encoded string. Put such string to the repository (or deployment) variable and name it KEY_FILE.

Regards, Galyna

More of the error. 

googlecloudsdk.api_lib.auth.service_account.BadCredentialFileException: Could not read json file /tmp/key-file.json: Expecting value: line 1 column 1 (char 0)

ERROR: (gcloud.auth.activate-service-account) Could not read json file /tmp/key-file.json: Expecting value: line 1 column 1 (char 0)

The strange part is that I can execute these commands just fine if I use a normal step script. Just having issues with the pipe itself.

script:

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

- gcloud config set project project-slug

- gcloud auth configure-docker --quiet

- gcloud app deploy --quiet

Hello, @Adam Woloszyn , you can recheck environment variable KEY_FILE. This should base64 encoded string , not filename. So the setting would be

KEY_FILE: $(cat gcloud-api-key.json').

This json file should contain proper base64 content and

This can be a tricky part, but we have a guide for this

https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html#UseSSHkeysinBitbucketPipelines-UsemultipleSSHkeysinyourpipeline , section "Use multiple SSH keys in your pipeline".

You can use the same approach for your key.

 

We will update the documentation to be more clear in future releases

Jab Lazim I'm New Here Aug 26, 2021

Hi, @Adam Woloszyn .

 

Haven't you encountered on manual scripting below?

 

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

gcloud config set project project-slug

gcloud auth configure-docker --quiet

gcloud app deploy --quiet

 

Like `gcloud : command not found`

 

Also, I would like to ask if you resolved the original issue with `atlassian/google-app-engine-deploy:0.7.0`?

Hoping for your reply.

 

Thank you.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

104 views 1 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