Last active
October 30, 2023 18:36
-
-
Save rkJun/f524b393a123af67b203 to your computer and use it in GitHub Desktop.
Subversion integration with Slack
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
#!/bin/bash | |
# | |
# Bash script for Subversion integration with Slack | |
# | |
# 1. Save this file in /usr/bin as slack-svn | |
# 2. Make it executable: | |
# chmod +x /usr/bin/slack-svn | |
# 3. Put this line at the end of file of your_svn_repo/hooks/post-commit: | |
# slack-svn $REPOS $REV full_path_to_svn_directory | |
# 4. Edit this file, especially from line 16-20 and 27 (example given is for Redmine) | |
# | |
# Refs: | |
# - https://github.com/chriseldredge/git-slack-hook/blob/master/git-slack-hook | |
# - http://svnbook.red-bean.com | |
# - https://api.slack.com/docs/attachments | |
REPOS="$1" | |
REV="$2" | |
PATH="$3" | |
# Change these lines as needed | |
channel="#yourchannel" | |
username="svn" | |
iconurl="http://i.imgur.com/2RqyaIS.png" | |
org_name="yourslackorgname" | |
token="yourtoken" | |
# SVN Info | |
author=$(/usr/bin/svnlook author -r $REV $PATH) | |
commit_msg=$(/usr/bin/svnlook log -r $REV $PATH) | |
header="New commit:" | |
value="<http://redmine.org/projects/projectname/repository/revisions/$REV|$REV> $commit_msg" | |
attachments="[{ \"fallback\" : \"${header}\", \"color\" : \"good\", \"fields\" : [ {\"title\" : \"${author}\", \"value\" : \"${value}\"} ] }]" | |
#msg=$(echo -e "\"text\":\"${header}\", \"attachments\" : $attachments") | |
#payload="{${msg}, \"channel\": \"$channel\"" | |
#payload="$payload, \"username\": \"$username\"" | |
#payload="$payload, \"icon_url\": \"$iconurl\"" | |
#payload="$payload}" | |
payload="{\"channel\": \"$channel\" , \"text\": \"New commit: $value - $author\" }" | |
/usr/bin/curl \ | |
--data-urlencode "payload=$payload" \ | |
"https://${org_name}.slack.com/services/hooks/incoming-webhook?token=$token" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!