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

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

Adam Woloszyn May 14, 2020

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
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 15, 2020

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

Adam Woloszyn May 15, 2020

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

Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 15, 2020

@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)

Adam Woloszyn May 15, 2020

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,

Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 18, 2020

@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.

Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 30, 2021

@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

0 votes
Adam Woloszyn May 14, 2020

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

Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 15, 2020

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 August 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
AUG Leaders

Atlassian Community Events