带服务帐户的`gcloud source repos clone`无效

时间:2016-06-28 04:49:02

标签: google-cloud-platform gcloud

将我的个人项目部署到GCE(Google Compute Engine),我尝试在Google Cloud Platform中克隆git repo。但它没有用。我猜GCP中的git repo在内部使用code.google.com,这与服务帐户不兼容。它打印

Cloning into '/home/...'...
fatal: remote error: Invalid username/password.
You may need to use your generated googlecode.com password; see https://code.google.com/hosting/settings
ERROR: (gcloud.source.repos.clone) Command '['git', 'clone', 'https://source.developers.google.com/p/.../r/...', '/home/...', '--config', 'credential.helper="gcloud.sh"']' returned non-zero exit status 128

目前已登录...-compute@developer.gserviceaccount.com,图片为Debian(GCE默认值)

1 个答案:

答案 0 :(得分:1)

您的GCE实例是如何创建的?

您需要确保它具有https://www.googleapis.com/auth/source.full_control范围。要列出您可以运行的范围

gcloud compute instances describe INSTANCE_NAME \
    --zone=INSTANCE_ZON --format="yaml(serviceAccounts)"

如果您使用gcloud command to create the instance,则可以使用--scopes标志来包含源范围。

或者,如果您使用developer console创建GCE实例,请务必在“服务帐户”部分选择“允许对所有Cloud API的完全访问权限”。

相关问题