bash - 如何替换 cloudbuild.yaml 中的替换字符串

标签 bash google-app-engine google-cloud-build

如何替换 cloudbuild.yaml 中的替换字符串?

我想使用 cloudbuild 将应用引擎版本设置为 $TAG_NAME。由于该版本只接受连字符,我需要先将点替换为连字符。

我试过:

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy', '--no-promote', "--version=$(echo $TAG_NAME | sed 's/[.]/-/g')"]
timeout: '1600s'

但是得到了

ERROR: (gcloud.app.deploy) argument --version/-v: Bad value [$(echo 0.0.1a4 | sed 's/[.]/-/g')]: May only contain lowercase letters, digits, and hyphens. Must begin and end with a letter or digit. Must not exceed 63 characters.

最佳答案

我最终找到了解决方案

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args:
  - '-c'
  - |
    version=$TAG_NAME
    gcloud app deploy --version=${version//./-}
  entrypoint: bash

关于bash - 如何替换 cloudbuild.yaml 中的替换字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56251730/

相关文章:

linux - 如何在远程主机上运行 bash function()?在Ubuntu中

c - 我如何编写一个函数,它接受可变数量的参数(整数)并使用标准参数输出它们?

google-app-engine - 如何使用 Dockerfile 运行 Google 应用引擎服务器

java - Cross Group (XG) 交易中超过 5 个实体组

python - 谷歌应用引擎 : getting form fields

continuous-integration - 从 Google Cloud Build 访问存储在 Google Secret Manager 中的环境变量

bash - 使用 shell 脚本从日志中提取值

linux - 使用 Sed 提取多个文件中的标题

gcloud - 如何通过 gcloud cli args 或环境变量将 secretEnv 指定到 cloudbuild.yaml

kubernetes - 云构建Bazel错误: "kubectl toolchain was not properly configured so apply cannot be executed"