[英]GCP: Cloud Run preview build fails because of a missing tag "latest"
If have an issue where cloud build is failing on creating a preview build for use in github pull requests.如果遇到云构建无法创建用于 github 拉取请求的预览构建的问题。
I have我有
The following is my cloudbuild-preview.yaml
file.以下是我的
cloudbuild-preview.yaml
文件。 The failing step is the last one: "link revision on pull request"失败的步骤是最后一步: “拉取请求的链接修订”
steps:
- id: "build image"
name: "gcr.io/cloud-builders/docker"
args:
[
"build",
"-t",
"$_GCR_HOSTNAME/${PROJECT_ID}/${_SERVICE_NAME}:${_PR_NUMBER}-${SHORT_SHA}",
".",
]
- id: "push image"
name: "gcr.io/cloud-builders/docker"
args:
[
"push",
"$_GCR_HOSTNAME/${PROJECT_ID}/${_SERVICE_NAME}:${_PR_NUMBER}-${SHORT_SHA}",
]
- id: "deploy revision with tag"
name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
entrypoint: "gcloud"
args:
[
"beta",
"run",
"deploy",
"${_SERVICE_NAME}",
"--platform",
"managed",
"--region",
"${_REGION}",
"--image",
"$_GCR_HOSTNAME/${PROJECT_ID}/${_SERVICE_NAME}:${_PR_NUMBER}-${SHORT_SHA}",
"--tag",
"pr-${_PR_NUMBER}",
"--no-traffic",
]
- id: "link revision on pull request"
name: "$_GCR_HOSTNAME/${PROJECT_ID}/deployment-previews" # our custom builder
args:
[
"set",
"--project-id",
"${PROJECT_ID}",
"--region",
"${_REGION}",
"--service",
"${_SERVICE_NAME}",
"--pull-request",
"${_PR_NUMBER}",
"--repo-name",
"${_GITHUB_REPO}",
"--commit-sha",
"${SHORT_SHA}",
]
timeout: 1400s
options:
machineType: N1_HIGHCPU_8
substitutions:
_GCR_HOSTNAME: eu.gcr.io
_SERVICE_NAME: redacted-service
_REGION: europe-west4
_GITHUB_REPO: $(pull_request.pull_request.head.repo.full_name)
The execution fails with执行失败
Step #3 - "link revision on pull request": Error response from daemon: manifest for eu.gcr.io/redacted-org/deployment-previews:latest not found: manifest unknown: Failed to fetch "latest" from request "/v2/redacted-org/deployment-previews/manifests/latest".
Step #3 - "link revision on pull request": Using default tag: latest
Step #3 - "link revision on pull request": Pulling image: eu.gcr.io/redacted-org/deployment-previews
Starting Step #3 - "link revision on pull request"
What I don't undestand is why the sep is even looking for a:latest tag.我不明白的是为什么 sep 甚至在寻找 a:latest 标签。 There is none.
空无一人。 The above steps don't create one.
上述步骤不会创建一个。 The container registry does not contain one.
容器注册表不包含一个。 How to tell that build step to use the proper image tagged with
${_PR_NUMBER}-${SHORT_SHA}
?如何告诉构建步骤使用带有
${_PR_NUMBER}-${SHORT_SHA}
标记的正确图像? Where can I dive into the magic here?我在哪里可以深入了解这里的魔法? Where is the definition of this magic build step?!
这个神奇的构建步骤的定义在哪里?!
Thank you very much for any ideas.非常感谢您的任何想法。
When you don't specify an image tag, tools will always try to pull the :latest
image.当您不指定图像标签时,工具将始终尝试拉取
:latest
图像。 In Cloud Build, you can specify a specific version of a builder image by simply including the tag in the name for your build step:在 Cloud Build 中,您只需在构建步骤的名称中包含标签即可指定特定版本的构建器镜像:
- id: "link revision on pull request"
name: "$_GCR_HOSTNAME/${PROJECT_ID}/deployment-previews:${_PR_NUMBER}-${SHORT_SHA}" # our custom builder
args:
[
"set",
"--project-id",
"${PROJECT_ID}",
"--region",
"${_REGION}",
"--service",
"${_SERVICE_NAME}",
"--pull-request",
"${_PR_NUMBER}",
"--repo-name",
"${_GITHUB_REPO}",
"--commit-sha",
"${SHORT_SHA}",
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.