在由云构建触发的pub/sub消息中添加标签?
我有一个DevOps管道:
- 推到源代码分支 - >
- 云构建触发器构建docker映像 - >
- 构建完成后,将云酒吧/子消息推向云功能以部署VM。
我的问题是发送到云功能的酒吧/子消息。
我的云构建具有标签log-Test
,但我似乎无法将其传递给云功能。
这是来自Pub/sub打印功能中的JSON数据:
{
"id": "XXX",
"status": "SUCCESS",
"source": {
"repoSource": {
"projectId": "XXX",
"repoName": "XXX",
"commitSha": "XXX"
}
},
"createTime": "2022-06XXXXX",
"startTime": "2022-XXX:41:11XXX",
"finishTime": "2022-06-08T07XXX",
"results": {
"images": [
{
"name": "XXX",
"digest": "XXX",
"pushTiming": {
"startTime": "2022-06-XXX3733Z",
"endTime": "2022-0XXX26.388064947Z"
}
}
],
"buildStepImages": [
"XXX"
],
"buildStepOutputs": [
""
]
},
"steps": [
{
"name": "gcr.io/cloud-builders/docker",
"args": [
"build",
"-t",
"XXX",
"."
],
"timing": {
"startTime": "2022-06XXX169Z",
"endTime": "2022-06XXX16549Z"
...
"logging": "XXX",
"dynamicSubstitutions": XXX,
"pool": {}
},
"logUrl": "https://console.cloud.google.cXXX",
"substitutions": {
"TRIGGER_BUILD_CONFIG_PATH": "",
"REPO_NAME": "XXX",
"REVISION_ID": "XXX",
"COMMIT_SHA": "XXX",
"SHORT_SHA": "XXX",
"BRANCH_NAME": "master",
"REF_NAME": "master",
"TRIGGER_NAME": "logtest"
},
"tags": [
"trigger-XXX"
],
"timing": {
"FETCHSOURCE": {
"startTime": "2022-XXX109Z",
"endTime": "2022-0XXX9740Z"
},
"BUILD": {
"startTime": "2022-0XXXXX042Z",
"endTime": "2022-06-0XXXXX9576Z"
},
"PUSH": {
"startTime": "202XXXXXX218Z",
"endTime": "20XXXXX654Z"
}
},
"artifacts": {
"images": [
"gcr.io/XXX"
]
},
"queueTtl": "XXX",
"name": "projects/XXX/locations/global/builds/XXXX"
}
我感兴趣的字段是tag
在JSON中找到的字段:
"tags": [
"trigger-XXX"
],
但是给定字段中的值,此是一个自动生成的值,不包含预期的标签log-Test
。
我可以将标签传递到另一个字段吗?
I have a DevOps pipeline as such:
- Push to a Source Code branch ->
- Cloud Build trigger builds Docker image ->
- Upon finish of build, a Cloud Pub/Sub message is pushed to Cloud Functions to deploy the VM.
My question is with the Pub/Sub message sent to Cloud Functions.
I have the Cloud Build with a tag log-test
but I can't seem to pass it to Cloud Functions.
Here is the JSON data from Pub/Sub print out in Functions:
{
"id": "XXX",
"status": "SUCCESS",
"source": {
"repoSource": {
"projectId": "XXX",
"repoName": "XXX",
"commitSha": "XXX"
}
},
"createTime": "2022-06XXXXX",
"startTime": "2022-XXX:41:11XXX",
"finishTime": "2022-06-08T07XXX",
"results": {
"images": [
{
"name": "XXX",
"digest": "XXX",
"pushTiming": {
"startTime": "2022-06-XXX3733Z",
"endTime": "2022-0XXX26.388064947Z"
}
}
],
"buildStepImages": [
"XXX"
],
"buildStepOutputs": [
""
]
},
"steps": [
{
"name": "gcr.io/cloud-builders/docker",
"args": [
"build",
"-t",
"XXX",
"."
],
"timing": {
"startTime": "2022-06XXX169Z",
"endTime": "2022-06XXX16549Z"
...
"logging": "XXX",
"dynamicSubstitutions": XXX,
"pool": {}
},
"logUrl": "https://console.cloud.google.cXXX",
"substitutions": {
"TRIGGER_BUILD_CONFIG_PATH": "",
"REPO_NAME": "XXX",
"REVISION_ID": "XXX",
"COMMIT_SHA": "XXX",
"SHORT_SHA": "XXX",
"BRANCH_NAME": "master",
"REF_NAME": "master",
"TRIGGER_NAME": "logtest"
},
"tags": [
"trigger-XXX"
],
"timing": {
"FETCHSOURCE": {
"startTime": "2022-XXX109Z",
"endTime": "2022-0XXX9740Z"
},
"BUILD": {
"startTime": "2022-0XXXXX042Z",
"endTime": "2022-06-0XXXXX9576Z"
},
"PUSH": {
"startTime": "202XXXXXX218Z",
"endTime": "20XXXXX654Z"
}
},
"artifacts": {
"images": [
"gcr.io/XXX"
]
},
"queueTtl": "XXX",
"name": "projects/XXX/locations/global/builds/XXXX"
}
The field of interest to me is the tag
field found in the JSON:
"tags": [
"trigger-XXX"
],
But given the value in the field, this is an auto-generated value which does not contain the expected tag log-test
.
Is there another field I can pass my tag into?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
然而。令人惊讶的是,Pubsub都不是。文档应该有点过时,否则有一个错误。
无论如何,该功能正在广泛部署。它应该很快到达云功能。
您可以尝试使用云功能2NG gen。它基于云运行,但仍在预览中。该标签有可能工作(是否在开发的预览阶段尚未实施)。
Cloud Functions doesn't support the tags yet. Surprisingly, PubSub neither. The doc should be slightly out of date, or there is a bug.
Anyway, the feature is being deployed broadly. It should come soon to Cloud Functions.
You can have a try with Cloud Functions 2ng gen. It's based on Cloud Run, but still in preview. There is chance that the tag works (or not if it's not yet implemented at the preview stage of the development).