简体   繁体   English

Google Cloud Build git 对 Cloud Source Repositories 的身份验证

[英]Google Cloud Build git authentication to Cloud Source Repositories

I am trying to clone a GCP Cloud Source Repository (CSR) using Cloud Build.我正在尝试使用 Cloud Build 克隆 GCP Cloud Source Repository (CSR)。 when trying to clone the Repo in my Dockerfile, I get this error:尝试在我的 Dockerfile 中克隆 Repo 时,出现此错误:

fatal: could not read Username for 'https://source.developers.google.com': No such device or address

This appears to be an authentication error with git and CSR.这似乎是 git 和 CSR 的身份验证错误。

What I've tried: I have found https://cloud.google.com/build/docs/build-config-file-schema.network and this github issue https://github.com/GoogleCloudPlatform/cloud-builders/issues/343 .我试过什么:我发现https://cloud.google.com/build/docs/build-config-file-schema.network和这个 github 问题https://github.com/GoogleCloudPlatform/cloud-builders/问题/343 I may not have put them in the right place in the config file though.不过,我可能没有将它们放在配置文件中的正确位置。

I'm aware that I could just use an SSH key, but I'd like to use the "inherited" authentication if that's possible.我知道我可以只使用 SSH 密钥,但如果可能的话,我想使用“继承的”身份验证。 By "inherited" I mean use the cloud build service account. “继承”是指使用云构建服务帐户。

If anyone can help with the specific issue, that would be great.如果有人可以帮助解决特定问题,那就太好了。 However if you can enlighten me as to how authentication works from the Build to other GCP services that would be welcome.但是,如果您能告诉我从构建到其他 GCP 服务的身份验证是如何工作的,那将是受欢迎的。

-ps I'm actually installing via pip (just like the person in the GitHub issue linked above), but it needs to clone the repo first, and that's where the error is. -ps 我实际上是通过 pip 安装的(就像上面链接的 GitHub 问题中的人一样),但它需要先克隆 repo,这就是错误所在。

You can use the https://source.developers.google.com URL with a PAT(Personal Access Token) in the Dockerfile.您可以在Dockerfile 中将 https://source.developers.google.com URL 与 PAT(个人访问令牌)一起使用。

For that you need to generate a PAT.为此,您需要生成一个 PAT。

After generating the token, use it in the dockerfile as follows:生成token后,在dockerfile中使用,如下:

FROM gcr.io/cloud-builders/git

RUN git clone https://<PAT>@source.developers.google.com/p/<PROJECT_ID>/r/<REPO_NAME>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌云源存储库:权限被拒绝(公钥) - Google Cloud Source Repositories: Permission denied (publickey) 尝试使用 SSH 身份验证从 Google Cloud Source Repositories 克隆 repo - Trying to clone repo from Google Cloud Source Repositories using SSH authentication Cloud Build“Google Cloud Platform 无权列出存储库” - Cloud Build "Google Cloud Platform was not authorised to list repositories" 使用谷歌云 SDK Windows 10 上的身份验证方法获取 Git 推送到谷歌云源存储库的权限被拒绝(公钥) - Get Permission denied (publickey) for Git push to Google Cloud Source Repository with Google Cloud SDK authentication method on Windows 10 谷歌云构建神秘地错误 git 哈希 - Google Cloud Build mysteriously wrong git hashes 谷歌云平台中的身份验证 - Authentication in Google Cloud Platform 为什么我的 SSH 密钥不能用于 Google Cloud Source 存储库? - Why doesn't my SSH key work with Google Cloud Source repositories? 有没有办法使用 Python SDK 在 Google Cloud Source Repositories 存储库上创建一个新分支? - Is there a way to create a new branch on a Google Cloud Source Repositories repo using the Python SDK? 如何对 Google Cloud Build 进行身份验证以调用需要身份验证的 Cloud Run 服务? - How to authenticate a Google Cloud Build to invoke a Cloud Run service that requires authentication? 谷歌云构建、云运行、云 SQL Prisma 迁移 - Google Cloud Build, Cloud Run, Cloud SQL Prisma Migration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM