Skip to content

Commit 6e508fe

Browse files
author
欧俊
committed
对格式化字符串的应用
1 parent cd177ac commit 6e508fe

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
![Docker Automated build](https://img.shields.io/docker/automated/luacloud/devops.to.dingtalk.robots) ![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/luacloud/devops.to.dingtalk.robots)
2+
3+
[](https://developers.dingtalk.com/document/robots/custom-robot-access)
24
# docker-compose.yml
35
```yaml
46
version: "2.0"

src/azure.devops.notify.dingtalk.robots/AzureDevOps/WebHooksRequest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ public class WebHooksRequestPullRequestUpdatedResource : WebHooksRequest<PullReq
1212
public class WebHooksRequestWorkitemUpdatedResource : WebHooksRequest<WorkitemUpdatedResource>
1313
{
1414
}
15+
public class ReleaseUpdateInputDto
16+
{
17+
public DetailedMessage DetailedMessage { get; set; }
18+
}
1519
public class WebHooksRequestInputDto
1620
{
1721
public string SubscriptionId { get; set; }

src/azure.devops.notify.dingtalk.robots/Controllers/WebHookController.cs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,49 @@ public WebHookController(IDingTalkService dingTalkService, ILogger<WebHookContro
5454
_ => ""
5555
};
5656
/// <summary>
57+
/// 发布部署等待审批
58+
/// </summary>
59+
/// <param name="request"></param>
60+
/// <returns></returns>
61+
[HttpPost]
62+
public async Task<IActionResult> ReleaseUpdated([FromBody] WebHooksRequestPullRequestUpdatedResource request)
63+
{
64+
/*
65+
{
66+
"id": "487c2c58-a83c-44c1-8732-3c99975defb2",
67+
"eventType": "ms.vss-release.deployment-approval-pending-event",
68+
"publisherId": "rm",
69+
"message": {
70+
"text": "阶段 prod 上的发布 2109011 尚待 预先部署 审批。",
71+
"html": "阶段 <a href='https://team.lujing.tech/NewSoftCollection/XXXProject/_release?_a=environment-summary&definitionId=45&definitionEnvironmentId=361'>prod</a> 上的发布 <a href='https://team.lujing.tech/NewSoftCollection/XXXProject/_release?releaseId=17455&_a=release-summary'>2109011</a> 尚待 预先部署 审批。",
72+
"markdown": "[prod](https://team.lujing.tech/NewSoftCollection/XXXProject/_release?_a=environment-summary&definitionId=45&definitionEnvironmentId=361)上的发布 [2109011](https://team.lujing.tech/NewSoftCollection/XXXProject/_release?releaseId=17455&_a=release-summary)尚待 预先部署 审批"
73+
},
74+
"detailedMessage": {
75+
"text": "阶段 prod 上的发布 2109011 尚待 预先部署 审批。\r\n待定位置: 杜建鹏\r\n待定开始时间: 03-September-2021 01:52:24 PM (UTC)",
76+
"html": "阶段 <a href='https://team.lujing.tech/NewSoftCollection/XXXProject/_release?_a=environment-summary&definitionId=45&definitionEnvironmentId=361'>prod</a> 上的发布 <a href='https://team.lujing.tech/NewSoftCollection/XXXProject/_release?releaseId=17455&_a=release-summary'>2109011</a> 尚待 预先部署 审批。<br>待定位置: 杜建鹏<br>待定开始时间: 03-September-2021 01:52:24 PM (UTC)",
77+
"markdown": "阶段 [prod](https://team.lujing.tech/NewSoftCollection/XXXProject/_release?_a=environment-summary&definitionId=45&definitionEnvironmentId=361) 上的发布 [2109011](https://team.lujing.tech/NewSoftCollection/XXXProject/_release?releaseId=17455&_a=release-summary) 尚待 预先部署 审批。\r\n待定位置: 杜建鹏\r\n待定开始时间: 03-September-2021 01:52:24 PM (UTC)"
78+
},
79+
"resource": "由于大小限制,历史记录中不会显示资源详细信息",
80+
"resourceVersion": "3.0-preview.1",
81+
"resourceContainers": {
82+
"collection": {
83+
"id": "196f1fb9-5cca-476e-bf6b-1bfc354d09c7",
84+
"baseUrl": "https://team.lujing.tech/NewSoftCollection/"
85+
},
86+
"server": {
87+
"id": "93ebc1b4-e4e0-4d53-8037-4905cd8a4cb6",
88+
"baseUrl": "https://team.lujing.tech/"
89+
},
90+
"project": {
91+
"id": "4993cbb2-cf7e-4796-9844-9a36b1aec4b3",
92+
"baseUrl": "https://team.lujing.tech/NewSoftCollection/"
93+
}
94+
},
95+
"createdDate": "2021-09-03T13:52:32.171Z"
96+
}*/
97+
return Ok();
98+
}
99+
/// <summary>
57100
/// 拉取请求
58101
/// </summary>
59102
/// <param name="dto"></param>
@@ -266,7 +309,7 @@ public async Task<IActionResult> WorkitemUpdated([FromBody] WebHooksRequestInput
266309
o = string.Format($"{{0:{setting.Format}}}", o);
267310
n = string.Format($"{{0:{setting.Format}}}", n);
268311
}
269-
stringBuilder.AppendLine($"> {setting.Name}: {ch.OldValue} 更改为 {ch.NewValue}");
312+
stringBuilder.AppendLine($"> {setting.Name}: {o} 更改为 {n}");
270313
stringBuilder.AppendLine();
271314
}
272315
}

0 commit comments

Comments
 (0)