gcloud auth activate-service-account fails to execute --key-file command, when the key is passed as an environment variable
When including a script in the .gitlab-ci.yml as:
gcloud auth activate-service-account --key-file $GOOGLE_SERVICE_ACCOUNT_FILE
The $GOOGLE_SERVICE_ACCOUNT_FILE variable is declared in variable section and contains the key for service account, it gives following error: ERROR: (gcloud.auth.activate-service-account) unrecognized arguments: "service_account", "project_id": "the project id removed for security reasons", "private_key_id": .... the whole file
To search the help text of gcloud commands, run: gcloud help -- SEARCH_TERMS
The security key when used as a file works, implying that the key is healthy.
The whole script:
react_deploy: image: google/cloud-sdk:alpine stage: deploy before_script: - echo "Deploying React app" - echo "Authenticating" - gcloud auth activate-service-account --key-file $GOOGLE_SERVICE_ACCOUNT_FILE script: - cd folder1 - cd build - gsutil cp -r . gs://bucket_name after_script: - echo "Deploying Completed"