我做了什么:
- 我使用本指南在 jenkins docker 容器上设置了 gcloud: https ://firebase.google.com/docs/test-lab/continuous
我要执行的内容:
gcloud firebase test android run --app ./app/build/outputs/apk/app-debug.apk
我得到的错误:
ERROR: (gcloud.firebase.test.android.run) Unable to access the test environment catalog: ResponseError 403: Not authorized for project <project-id>
问题
我究竟做错了什么?我尝试使用所有服务帐户规则在 IAM 下添加服务帐户,但这没有帮助。
是否可以专门为服务帐户启用这些 API?我只为完整的项目和 gmail 帐户这样做:启用所需的 API。使用服务帐户登录后:“在 Google Developers Console API 库页面中,启用 Google Cloud Testing API 和 Cloud Tool Results API。要启用这些 API,请在控制台顶部的搜索框中输入这些 API 名称,然后在该 API 的概述页面上单击启用 API。"
到目前为止,我的详细步骤:
docker exec -it container bash
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install google-cloud-sdk
gcloud init
# only if this service account does not already exist:
# gcloud iam service-accounts create continuous-integration
gcloud iam service-accounts keys create $JENKINS_HOME/gce-continuous-integration-key.json --iam-account=continuous-integration@<project-id>.iam.gserviceaccount.com
gcloud auth activate-service-account continuous-integration@<project-id>.iam.gserviceaccount.com --key-file=$JENKINS_HOME/gce-continuous-integration-key.json
gcloud auth login continuous-integration@<project-id>.iam.gserviceaccount.com
jenkins@VM:/$ gcloud config list
# returns:
[compute]
region = europe-west3
zone = europe-west3-c
[core]
account = continuous-integration@<project-id>.iam.gserviceaccount.com
disable_usage_reporting = True
project = <project-id>
Your active configuration is: [default]