cil*_*hex 0 google-cloud-platform google-cloud-build
我在 Google Cloud 中设置了自动构建,因此每次推送到存储库的 master 分支时,都会构建一个新映像并将其推送到 Google Container Registry。
这些图像堆积得很快,我不需要所有旧的。因此,我想添加一个构建步骤,该步骤运行 bash 脚本,该脚本调用gcloud container images list-tags、循环结果并使用gcloud container images delete.
我写了脚本,它在本地工作。我无法弄清楚如何将它作为 Cloud Builder 中的一个步骤运行。
似乎有2个选择:
- name: 'ubuntu'
args: ['bash', './container-registry-cleanup.sh']
Run Code Online (Sandbox Code Playgroud)
在上面的步骤中,cloudbuild.yml我尝试运行图像中的bash命令ubuntu。这不起作用,因为gcloud此图像中不存在该命令。
- name: 'gcr.io/cloud-builders/gcloud'
args: [what goes here???]
Run Code Online (Sandbox Code Playgroud)
在上面的步骤中cloudbuild.yml我尝试使用gcloud图像,但由于“传递给此构建器的参数将直接传递给gcloud”,我不知道如何在此处调用我的 bash 脚本。
我能做什么?
您可以自定义构建步骤的入口点。如果您需要安装 gcloud,请使用 gcloud 云构建器并执行此操作
step:
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: "bash"
args:
- "-c"
- |
echo "enter 1 bash command per line"
ls -la
gcloud version
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2245 次 |
| 最近记录: |