带有服务帐户的“gcloud源回购克隆”不起作用 [英] `gcloud source repos clone` with service account is not working

查看:199
本文介绍了带有服务帐户的“gcloud源回购克隆”不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 克隆到'/ home / ...'... 
致命错误:远程错误:无效的用户名/密码。
您可能需要使用您生成的googlecode.com密码;请参阅https://code.google.com/hosting/settings
错误:(gcloud.source.repos.clone)命令'['git','clone','https://source.developers.google .com / p /.../ r / ...','/ home / ...','--config','credential.helper =gcloud.sh']'返回非零退出状态128

当前登录 ...- compute@developer.gserviceaccount.com 和image是Debian(GCE默认)

解决方案

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



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

  gcloud计算实例描述INSTANCE_NAME \ 
--zone = INSTANCE_ZON --format = yaml(serviceAccounts)

如果您使用 gcloud命令来创建实例,您可以使用 - scopes 标志以包含源作用域。

或者,如果您使用开发人员控制台

a>创建GCE实例,请务必在服务帐户部分选择允许完全访问所有Cloud API。


Deploying my personal project to GCE(Google Compute Engine), I tried to clone a git repo in Google Cloud Platform. But it did not work. I guess git repo in GCP uses code.google.com internally, and that is not compatible with service accounts. It prints

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

Currently logged in ...-compute@developer.gserviceaccount.com and image is Debian (GCE default)

解决方案

How was your GCE instance created?

You need to make sure it has https://www.googleapis.com/auth/source.full_control scope. To list scopes you can run

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

If you used gcloud command to create the instance you can use --scopes flag to include the source scope.

Alternatively if you use developer console to create the GCE instance make sure to select "Allow full access to all Cloud APIs" in "Service account" section.

这篇关于带有服务帐户的“gcloud源回购克隆”不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆