3
$ echo $SERVICE_ACCOUNT_DEV > ${HOME}/gcloud-service-key.json
$ gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
ERROR: (gcloud.auth.activate-service-account) Could not read json file /root/gcloud-service-key.json: Expecting value: line 2 column 1 (char 1).

I checked the SERVICE_ACCOUNT_DEV json file stored in gitlab ci/cd variable but there is no issue with it.

Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29
Tino
  • 45
  • 1
  • 5
  • Have you checked this [question](https://stackoverflow.com/questions/16573332/jsondecodeerror-expecting-value-line-1-column-1-char-0)? Do you use [protected branches](https://docs.gitlab.com/ee/user/project/protected_branches.html) or/and [protected variables](https://docs.gitlab.com/ee/ci/variables/)? – Serhii Rohoza Oct 12 '20 at 08:19
  • 1
    Thanks! that was the issue. I added the variable as protected and didn't add the brach as protected. Making the branch and variable protected solved the issue – Tino Oct 12 '20 at 08:28
  • Thanks! I posted an answer, please upvote/accept it if my comment was helpful. – Serhii Rohoza Oct 12 '20 at 08:40

1 Answers1

5

Have a look at the documentation Protected branches and GitLab CI/CD environment variables. Variables can be protected. Whenever a variable is protected, it would only be securely passed to pipelines running on the protected branches or protected tags. The other pipelines would not get any protected variables. So, if the you have a protected variables then it will be only available for protected branches.

As it was confirmed at the comment section, making the branch and variable protected solved the issue.

Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29