regex - 传递项目 ID 时 cloudbuild.yaml 文件中的正则表达式错误
问题描述
我正在尝试使用云构建运行数据流作业
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
dataflow
jobs
run
google-template-job
--gcs-location=gs://dataflow-templates/latest/PubSub_Subscription_to_BigQuery
--parameters=inputSubscription='projects/$PROJECT_ID/subscriptions/messages'
--parameters=outputTableSpec="$PROJECT_ID:beam_samples.streaming_beam"
--staging-location=gs://cloudbuild-dataflow-testproject123456789-313307/tmp'
--region=us-central1
每次触发构建时,都会出现以下错误
ERROR: (gcloud.dataflow.jobs.run) INVALID_ARGUMENT: The template parameters are invalid.
- '@type': type.googleapis.com/google.dataflow.v1beta3.InvalidTemplateParameters
parameterViolations:
- description: 'Unmatched regex: ^projects\/[^\n\r\/]+\/subscriptions\/[^\n\r\/]+$'
parameter: inputSubscription
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1
我的项目 ID 中有一个“-”,所以如果我用项目 ID 的值替换 $PROJECT_ID,我仍然会遇到同样的错误,是否有任何解决方法。我无法控制停止正则表达式检查,因为它是谷歌提供的模板。
我如何克服这个
解决方案
知道了。这只是一个命令解释器问题。如果你放单引号,你会阻止对内部字符串的任何评估。
在你的情况下
--parameters=inputSubscription='projects/$PROJECT_ID/subscriptions/messages'
该值'projects/$PROJECT_ID/subscriptions/messages'
按原样采用,因此项目 ID 包含大写和下划线,这违反了正则表达式模式。
更改为双引号,它应该很好用!
--parameters=inputSubscription="projects/$PROJECT_ID/subscriptions/messages"
推荐阅读
- excel - VBA UsedRanges when 0
- pandas - Dask Dataframe: Defining meta for date diff in groubpy
- dynamics-business-central - 我们可以在 AL BC365 的页面或页面扩展中使用两个或更多源表吗?
- swift - 如果我快速按下一个按钮,如何让另一个按钮出现
- java - DeviceDriver connection statement not executing
- javascript - 这个 JavaScript 函数是否具有线性或二次时间复杂度?
- xml - XSLT - 如何存储从源文档中删除的一组元素以供重用
- c# - 如何捕获 1000 个随机整数的最小值和最大值?
- arrays - 按包含字符串的列之一对 Julia 1.1 矩阵进行排序
- python - 确定带宽数据中的“噪声”