Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version of trac integration for slack
- Loading branch information
Gregor Dorfbauer
committed
Apr 1, 2014
1 parent
42bde7c
commit 2e4f094
Showing
4 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Trac Notifications for Slack | ||
============================ | ||
|
||
[Trac](http://trac.edgewall.org/) has really nice email notifications for tickets: | ||
``` | ||
#25: Please check in the new admin scripts | ||
---------------------------+------------------------- | ||
Reporter: gregi | Owner: robert | ||
Type: enhancement | Status: new | ||
Priority: major | Milestone: Ready To Do | ||
Resolution: | Keywords: | ||
Action Item: | | ||
---------------------------+------------------------- | ||
Changes (by gregi): | ||
* milestone: Backlog => Ready To Do | ||
-- | ||
Ticket URL: [...] | ||
``` | ||
|
||
Having those handy notifications on changes directly in [Slack](https://slack.com/) enhances productivity! | ||
|
||
![Trac Slack integration](slack.png) | ||
|
||
|
||
Installing | ||
========== | ||
|
||
On your machine running trac, add a ```slack``` user and save ```tracslack.py``` in his ```$HOME```. | ||
|
||
Edit the ```.forward``` file of this user with this content: | ||
|
||
|/home/slack/tracslack.py | ||
|
||
|
||
Finally, adjust your ```trac.ini``` and add the local slack user as an ```smtp_always_cc``` option. | ||
|
||
[notification] | ||
smtp_always_cc = slack@localhost | ||
|
||
Configuration | ||
============= | ||
You need to setup an "Incoming Webhook" inside Slack. Afterwards set the ```SLACK_URL``` and ```SLACK_TOKEN``` inside tracslack.py: | ||
|
||
SLACK_URL="https://yourcompany.slack.com/services/hooks/incoming-webhook" | ||
SLACK_TOKEN="ABc293jBlPyktTIasdagasd" | ||
|
||
Additionally, you can adjust the channel, username and even the emoji of the trac messages: | ||
|
||
SLACK_CHANNEL="#trac" | ||
SLACK_USERNAME="trac" | ||
SLACK_EMOJI=":rocket:" | ||
|
||
Meta | ||
==== | ||
Maintained by Gregor Dorfbauer [@dorfbauer](https://twitter.com/dorfbauer) | ||
|
||
If you like those scripts, have a look at my startup [Usersnap](https://usersnap.com/?gat=github) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
SVN branching aliases | ||
===================== | ||
|
||
SVN branching is a little painful on the command line. For all those who worked with giti | ||
a single minute of their lives, it's really frustrating. | ||
|
||
But it doesn't need to be so complicated. This bash aliases (they work on zsh, too) provide | ||
commands for easier svn branching, merging and reintegrating. | ||
|
||
Installing | ||
========== | ||
|
||
Fetch the branchit.rc file into your home directory and integrate it into your dotfile (.bashrc or .zshrc) | ||
|
||
. ~/branchit.rc | ||
|
||
Restart your shell and off you go! | ||
|
||
Examples | ||
======== | ||
|
||
create a branch: | ||
|
||
svnbr "branchname" "commit message" | ||
|
||
update a branch from the trunk: | ||
|
||
svnupbr | ||
|
||
delete a branch: | ||
|
||
svndelbr $branchname | ||
|
||
switch between trunk / branches: | ||
|
||
svnsw trunk | ||
svnsw branches/$branchname | ||
|
||
Reintegrate a branch back into the trunk: | ||
|
||
svnre $branchname "commit message" | ||
|
||
Meta | ||
==== | ||
Maintained by Gregor Dorfbauer @dorfbauer | ||
|
||
If you like those scripts, have a look at my startup [Usersnap](http://usersnap.com) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/python | ||
|
||
# Send Trac ticket updates to Slack | ||
# | ||
# Written by Gregor Dorfbauer / gd@usersnap.com | ||
# http://usersnap.com - Show, don't tell. | ||
# | ||
# | ||
# Setup Steps: | ||
# update your trac.ini | ||
# #################### | ||
# [notification] | ||
# smtp_always_cc = slack@localhost | ||
# #################### | ||
# invoke with a .forward file of your slack user - content "|/home/slack/tracslack.py" | ||
|
||
import sys | ||
import json | ||
import requests | ||
import email | ||
import base64 | ||
|
||
LOGFILE="/home/slack/log.txt" | ||
SLACK_URL="https://yourcompany.slack.com/services/hooks/incoming-webhook" | ||
SLACK_TOKEN="ABc293jBlPyktTIasdagasd" | ||
|
||
#those are free to choose | ||
SLACK_CHANNEL="#trac" | ||
SLACK_USERNAME="trac" | ||
SLACK_EMOJI=":rocket:" | ||
|
||
|
||
############################################################################### | ||
ofile = open(LOGFILE, "a") | ||
|
||
firstempty = False | ||
subject = "" | ||
content = email.message_from_string(sys.stdin.read()) | ||
payload = content.get_payload() | ||
try: | ||
payload = base64.decodestring(payload) | ||
except: | ||
pass | ||
newcont = [] | ||
omitheader = 2 | ||
ofile.write("Payload: %r" % payload) | ||
for line in payload.split("\n"): | ||
ofile.write("line %r" % line) | ||
#filter out header + lines (free to extend) | ||
if omitheader == 2 and "-----+-----" in line: | ||
omitheader -= 1 | ||
continue | ||
if omitheader == 1: | ||
if "-----+-----" in line: | ||
omitheader -= 1 | ||
continue | ||
if line in ("-- ", ""): | ||
continue | ||
newcont.append(line) | ||
|
||
ofile.write("newcont: %r" % newcont) | ||
|
||
data = {"channel": SLACK_CHANNEL, | ||
"username": SLACK_USERNAME, | ||
"text": "%s"% ("\n".join(newcont)), | ||
"icon_emoji": SLACK_EMOJI | ||
} | ||
ofile.write("got mail\n") | ||
ofile.write(json.dumps(data,indent=2)) | ||
r = requests.post(SLACK_URL, data={"token": SLACK_TOKEN, "payload":json.dumps(data)}) | ||
ofile.write("r.status %r r.text %r " % (r.status_code, r)) | ||
ofile.write("\n\n") | ||
|
||
|