Tools to integrate Fabric with Slack
Python
Latest commit ba592e9 Oct 27, 2016 @erans committed on GitHub Merge pull request #5 from JulienBreux/patch-1
Allow to set data (for eg: icon)
Permalink
Failed to load latest commit information.
fabric_slack_tools Allow to set data (for eg: icon) Oct 26, 2016
.gitignore Initial commit Jan 18, 2015
LICENSE Initial commit Jan 18, 2015
README.md Fix another typo Mar 28, 2015
setup.py initial commit Jan 18, 2015

README.md

fabric-slack-tools - Tools to integrate Fabric with Slack

Easily send messages during your deployments or any other Fabric command using slack.

Installation

  • pip install fabric-slack-tools

Slack webhook setup

Create an incoming webhook on Slack integration configuration. There, you will be asked which user to post as and which channel to announce to. This means you only need send data to the webhook URL, no need for any other configuration on client side other than the URL itself and the message to announce.

However, if you want to customise the channel and username, you can still do that by specifying the optional parameters in the announce_deploy annotation.

You can always override the relevant parameters in the code and pass the channel or username in the decorator call (see one of the examples below).

Example fabfile

  • Minimal setup, with channel and username set on Slack settings:
from fabric.api import *
from fabric_slack_tools import *

def do_build():
    send_slack_message("This is the text")

@roles("webserver")
@announce_deploy("MyProject")
def deploy_server():
    run("do something")

@roles("webserver")
@announce_deploy("MyProject", channel="anotherchannel", username="the other bot")
def deploy_something_else():
    run("do something")


init_slack("https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZZZ")
  • To announce to a specific channel or want your bot to act under a particular username, you can do:
@roles("webserver")
@announce_deploy("MyProject", channel="#devops", username="deployment-bot")
def deploy_server():
    run("do something")