【问题标题】:How to get a specific tag from Google GCR with regex using gcloud如何使用 gcloud 使用正则表达式从 Google GCR 获取特定标签
【发布时间】:2021-06-17 06:32:15
【问题描述】:

我正在使用 git_short_sha 和 branch_name 以及其他一些标签来标记我的图像。我正在尝试使用 gcloud 命令获取带有 master 标记的图像的 short_sha 标记。 我已经设法使用这些命令获取所有标签或特定标签的位置:

1. gcloud container images list-tags eu.gcr.io/${PROJECT_ID}/${IMAGE} --format='value(tags[1])' --filter="tags=master"

result:
76f1a2a

但我不能确定第二个元素将始终是 short_sha。

 2. gcloud container images list-tags eu.gcr.io/${PROJECT_ID}/${IMAGE} --format='value(tags)' --filter="tags=master"

result:
1.0.0-master,76f1a2a,76f1a2a-master,master

仅使用gcloud命令是否可以仅获取short_sha标签?

【问题讨论】:

    标签: google-cloud-platform gcloud google-container-registry


    【解决方案1】:

    试试:

    gcloud container images list-tags eu.gcr.io/${PROJECT_ID}/${IMAGE} \
    --flatten="[].tags[]" \
    --filter="tags=${TAG}"
    

    这出现了一次before。如果您遇到该错误,您可以尝试jq 解决方案。

    【讨论】:

      猜你喜欢
      • 2013-09-10
      • 1970-01-01
      • 2017-02-15
      • 1970-01-01
      • 1970-01-01
      • 2016-10-14
      • 1970-01-01
      • 2021-12-30
      • 1970-01-01
      相关资源
      最近更新 更多