Roswell Studios

139 Fulton Street, Ste 132
New York, NY 10038

Slack + SVN

— September 1, 2016

Git has all sorts of Slack integrations. I’m a bigger fan of git once I found the max-depth thing, the exact syntax of which I’ve already forgotten. (so cloning a repo doesn’t download the entire repo history, which may include massive media files or entirely different websites) However, I still like svn.

In an effort to increase our velocity or flywheel or other business sounding keywords (but mostly because jira’s chatter already rendered the channel unreadable), I connected it to SVN.

This is largely from

how to Slack+SVN

  1. Add this to hooks/post-commit in your repo:
    /usr/bin/slack-svn $REPOS $REV /var/svn/repo/ 

    and make that file chmod a+x post-commit. Very important!

  2. Go to your team’s Slack page, add a Custom Integration, Incoming Webhook. Customize the name, logo. Note the Webhook URL.
  3. Put this in /usr/bin/slack-svn:
    # Change these lines as needed
    # SVN Info
    author=$(/usr/bin/svnlook author -r $REV $PATH)
    commit_msg=$(/usr/bin/svnlook log -r $REV $PATH)
    header="New commit:"
    value="$REV  $commit_msg"
    attachments="[{ \"fallback\" : \"${header}\", \"color\" : \"good\", \"fields\" : [ {\"title\" : \"${author}\", \"value\" : \"${value}\"} ] }]"
    msg=$(echo -e "\"text\":\"${header}\", \"attachments\" : $attachments")
    /usr/bin/curl \
      --data-urlencode "payload={${msg}}" \

    Change the hookurl to your url. chmod a+x /usr/bin/slack-svn Important: this gets run with no ENV vars, esp. PATH, so you have to use the full path for everything you call.

  4. Customize it with any of the other things svnlook can return, or shorten it by putting the fields data into the text.
Back to all