Last active
November 18, 2015 22:53
-
-
Save DamianStanger/ac1b1987fd6fc881ccba to your computer and use it in GitHub Desktop.
A basic method of getting svn checkins to slack using the svn post commit hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set REPOS=%1 | |
| set REV=%2 | |
| C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -file SvnSlackHook.ps1 %REV% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param([String]$revision) | |
| $log = & 'C:\Program Files (x86)\VisualSVN Server\bin\svn.exe' --username myUser --password foobarfoobar log https://svnRepo/svn/folder -r $revision | |
| $revisionIndex = $log[1].IndexOf("|") | |
| $revision = $log[1].Substring(0,$revisionIndex) | |
| $committer = $log[1].Split("|")[1] | |
| $logMsg = $log[3] | |
| $mingleNumberFound = $logMsg -match "m#([0-9]+)" | |
| if($mingleNumberFound){ | |
| $mingleNumberString = $Matches[0] | |
| $mingleNumber = $Matches[1] | |
| $logMsg = $logMsg -replace $mingleNumberString, "<https://PROJ.mingle.thoughtworks.com/projects/PROJ/cards/$mingleNumber|$mingleNumberString>" | |
| } | |
| $body = '{"text": "<https://svnRepo/!/#folder/commit/' + $revision + '|' + $revision +'> | ' + $logMsg + '", "username": "SVN - ' + $committer + '", "channel": "#commit-log", "icon_emoji": ":large_blue_diamond:"}' | |
| Invoke-WebRequest -Uri https://hooks.slack.com/services/AAAAAAAAA/BBBBBBBBB/CCCCCCCCC -Method POST -ContentType "application/json" -body $body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment