gcloud Firebase Android 测试:无法访问测试环境目录:ResponseError 403: Not authorized for project
gcloud Firebase Android Test: Unable to access the test environment catalog: ResponseError 403: Not authorized for project
我做了什么:
- 我使用本指南在 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。使用服务帐户登录后:"In the Google Developers Console API Library page, enable the Google Cloud Testing API and Cloud Tool Results API. To enable these APIs, type these API names into the search box at the top of the console, and then click Enable API on the overview page for that 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]
尝试在 IAM 页面中授予服务帐户项目->编辑权限。要 运行 Firebase 测试实验室测试,授权需要允许 gcloud 创建多种类型的云资源(测试矩阵、工具结果)以及将中间和最终测试结果文件写入项目的云存储桶。
编辑角色对我不起作用,在我的例子中,我是从 IAM 页面创建服务帐户,但结果发现那里缺少一些东西,所以你需要做的是 "generate a private key" 在 https://console.firebase.google.com/u/0/project/my-project/settings/serviceaccounts/adminsdk
我的意思是:Settings/Service accounts/Firebase Admin SDK -> 生成私钥。
我做了什么:
- 我使用本指南在 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。使用服务帐户登录后:"In the Google Developers Console API Library page, enable the Google Cloud Testing API and Cloud Tool Results API. To enable these APIs, type these API names into the search box at the top of the console, and then click Enable API on the overview page for that 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]
尝试在 IAM 页面中授予服务帐户项目->编辑权限。要 运行 Firebase 测试实验室测试,授权需要允许 gcloud 创建多种类型的云资源(测试矩阵、工具结果)以及将中间和最终测试结果文件写入项目的云存储桶。
编辑角色对我不起作用,在我的例子中,我是从 IAM 页面创建服务帐户,但结果发现那里缺少一些东西,所以你需要做的是 "generate a private key" 在 https://console.firebase.google.com/u/0/project/my-project/settings/serviceaccounts/adminsdk
我的意思是:Settings/Service accounts/Firebase Admin SDK -> 生成私钥。