[英]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.