forked from tinyspeck/services-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subversion.ps1
43 lines (38 loc) · 1.3 KB
/
subversion.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
# Requires Powershell 3.0
#
# An SVN post-commit handler for posting to Slack. Setup the channel and get the token
# from your team's services page. Change the options below to reflect your team's settings.
Param(
[string]$svnPath,
[string]$revision,
[string]$repoName
)
$domain = "YOUR_DOMAIN.slack.com"
$token = "TOKEN"
$endpoint = "https://${domain}/services/hooks/subversion?token=${token}"
#$revisionUrlBase = "WEB_VIEW_BASE URL" #if any
$log = (svnlook log -r $revision $svnPath)
$who = (svnlook author -r $revision $svnPath)
$changes = (svnlook changed -r $revision $svnPath)
$changes = [string]::Join("`r`n", $changes) # $changes was an array of strings
$payload = @{
attachments = @(@{
pretext = "Commit completed: $repoName rev. $revision"
text = "Message: $log"
fallback = "Commit completed: $repoName rev. $revision"
title = "Commit details"
# title_link = "$revisionUrlBase$revision"
color = '#439FE0'
fields = @(@{
title = "Changes"
value = $changes
short = $false
}, @{
title = "Author"
value = $who
short = $true
})
})
}
$json = (ConvertTo-Json $payload -Depth 99)
Invoke-RestMethod -Uri $endpoint -Method Post -ContentType "application/json" -Body $json