์์ฉ๋ถํฐ ๋งํ๋ฉด
- redmine, jira์ ๋ด๊ฐ ๋ด๋น์ด ๋ ํฐ์ผ์ด ์ฌ๋ผ์์ ๋,
- gitlab, github, bitbucket, jetbrains space ์ MR์ด ์์ ๋
- ํต์ง๋ ๋ฉ์ผ, chatwork, slack, line, kakao ๋ฑ๋ฑ API๋ฅผ ์ง์ํ๋ ์ด๋๊ฒ์ด๋
๋ด์ฉ์ ๋น์ทํฉ๋๋ค. scheduled job์ผ๋ก ํ๋ ๋ฐฉ๋ฒ๋ ๊ฐ OS์ ์๋ ๋ฐฉ๋ฒ์ผ๋ก ํ๋ฉด ๋ฉ๋๋ค.
์ธ์ด๋ ์ฌ๋ฌ ์ธ์ด๋ก ๊ตฌ์ฑํด๋ ๋ฉ๋๋ค๋ง, ํ์ฌ ์๋์ฐ์ฆ VM๊ฐ ์
๋ฌด์ ์ง๊ธ๋์ด ์์ผ๋ฏ๋ก powershell๋ก ํ๋ฉด ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
assignee.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
| [CmdletBinding()]
param(
[string]
$gitlab_token = "my_gitlab_token",
[string]
$chatwork_token = "my_chatwork_token",
[string]
$chatwork_roomid = "my_room_id",
[string]
$cache = "c:\dc\.notified"
)
. c:\dc\users.ps1
# get merge_requests, opened, and assigned to someone
$groupid = 1234
$Uri = "https://gitlab.tkim.info/api/v4/groups/$groupid/merge_requests?state=opened&assginee_id=Any"
try {
$merge_requests = Invoke-RestMethod `
-Uri $Uri `
-Method Get `
-Headers @{ "PRIVATE-TOKEN" = $gitlab_token }
}
catch {
throw $_
}
$merge_requests = $merge_requests | Where-Object { $_.assignee }
# get notified list
$notified = Get-Content -Path $cache | ConvertFrom-Json
if ($null -eq $notified) {
$notified = @()
}
# get merge_requests, which is not notified yet
$new_merge_requests = $merge_requests | Where-Object { $_.id -notin $notified }
if (-not $new_merge_requests) {
exit 0
}
# build messages
$messages = [Users].GetEnumNames() | ForEach-Object {
$id = [int]([Users]::$_)
return @{
assignee = $_
merge_requests = ($new_merge_requests | Where-Object { $_.assignee.id -eq $id }).web_url
}
}
$body = ""
$messages | ForEach-Object {
if ($_.merge_requests) {
$id = [int]([ChatworkUsers]::($_.assignee))
$body += "[To:$id] Please review these merge requests:`r`n"
$_.merge_requests | ForEach-Object {
$body += " $_`r`n"
}
$body += "`r`n"
}
}
# send
if ($body) {
$Uri = "https://api.chatwork.com/v2/rooms/$($chatwork_roomid)/messages"
try {
Invoke-RestMethod `
-Uri $Uri `
-Method Post `
-Headers @{ "X-ChatworkToken" = $chatwork_token } `
-Body @{"body" = $body }
}
catch {
throw $_
}
# append notified
Set-Content $cache ($new_merge_requests.id + $notified | ConvertTo-Json -Compress)
}
|
๋ค์์ ์ด๋ฏธ์ง๋, ๊ทธ์ ๋จ์์๋ MR์ด ์๋ค๋ ํ๋ฉด์
๋๋ค. :-)
Ref