Created
April 17, 2015 15:43
-
-
Save krewenki/c3de830da21023367cd5 to your computer and use it in GitHub Desktop.
Slack SVN post-commit in PHP
This file contains 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
<?php | |
# 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. | |
# | |
$opt_domain = ""; # Your team's domain | |
$opt_token = ""; # The token from your SVN services page | |
exec("/usr/bin/svnlook log -r $argv[2] $argv[1]", $log); | |
exec("/usr/bin/svnlook author -r $argv[2] $argv[1]", $who); | |
$log = implode("\n", $log); | |
$who = implode("\n", $who); | |
$payload = new stdClass; | |
$payload->revision = $argv[2]; | |
$payload->url = ''; | |
$payload->author = $who; | |
$payload->log = $log; | |
$url = "https://".$opt_domain."/services/hooks/subversion?token=".$opt_token; | |
$ch = curl_init(); | |
//set the url, number of POST vars, POST data | |
curl_setopt($ch,CURLOPT_URL, $url); | |
curl_setopt($ch,CURLOPT_POST, true); | |
curl_setopt($ch,CURLOPT_POSTFIELDS, "payload=".urlencode(json_encode($payload))); | |
//execute post | |
$result = curl_exec($ch); | |
//close connection | |
curl_close($ch); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment