我正在将CI/CD系统的结果/日志发布到Microsoft Teams。在处理一些具有较长结果的失败构建时,我遇到了由Webhook URL返回的以下错误:https://outlook.office.com/webhook/bb6bfee7-1820-49fd-b9f9-f28f7cc679ff@<uuid1>/IncomingWebhook/<id>/<uuid2>
:
Webhook message delivery failed with error: Microsoft Teams endpoint returned HTTP error 413 with ContextId tcid=3626521845697697778,server=DB3PEPF0000009A,cv=BmkbJ1NdTkv1EDoqr7n/rg.0..
根据我的观察,这是由于发布到 Teams webhook URL 的负载过长所致。
当 JSON 负载超过 18000 个字符时,初始的复杂信息(包括部分、标题、子标题、格式化链接、
<pre>
格式文本等)会失败。通过对负载进行一些测试,我发现从原始 JSON 负载中删除的格式化内容越多,Teams 消息就可以越长。我能够发布的最长消息为(根据 cu cURL):
Content-Length: 20711
。此消息的 JSON 负载如下:{"themeColor":"ED4B35","text":"a....a"}
JSON格式中的空格似乎不计算在内(即添加空格不会减少我可以发送到Teams Webhook的最大消息长度)。
供参考,初始消息看起来类似于这样:
{
"themeColor": "ED4B35",
"summary": "iris-shared-libs - shared-library-updates - failure",
"sections": [
{
"activityTitle": "Job: [iris-shared-libs](https://my.concourse.net/teams/hsm/pipelines/iris-shared-libs) - [shared-library-updates #89](https://my.concourse.sccloudinfra.net/teams/hsm/pipelines/iris-shared-libs/jobs/shared-library-updates/builds/89) (FAILURE)",
"activityImage": "https://via.placeholder.com/200.png/ED4B35/FFFFFF?text=F",
"facts": [
{
"name": "Failed step",
"value": "update-shared-libraries"
}
]
},
{
"text": "Trying a new strategy with gated versioned releases",
"facts": [
{
"name": "Repository",
"value": "[iris-concourse-resources](https://my.git.com/projects/IRIS/repos/iris-concourse-resources)"
},
{
"name": "Commit",
"value": "[2272145ddf9285c9933df398d63cbe680a62f2b7](https://my.git.com/projects/IRIS/repos/iris-concourse-resources/commits/2272145ddf9285c9933df398d63cbe680a62f2b7)"
},
{
"name": "Author",
"value": "me@company.com"
}
]
},
{
"activityTitle": "Job failed step logs part 1",
"text": "<pre>...very long log text goes here ...</pre>"
}
]
}
微软团队连接器Webhook发布的消息的实际最大长度是多少?
官方页面没有提到。在底部的反馈部分仍有一个关于“消息大小限制?”的未解决问题,反馈为:“我们目前正在调查此问题。”