From a4c92ff7477d09b480cab028411bc7c6b250604e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 5 Mar 2018 17:29:29 +0100 Subject: Add notification for app deployment --- modules/role/files/cryptoportfolio/slack-notify.py | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 modules/role/files/cryptoportfolio/slack-notify.py (limited to 'modules/role/files/cryptoportfolio/slack-notify.py') diff --git a/modules/role/files/cryptoportfolio/slack-notify.py b/modules/role/files/cryptoportfolio/slack-notify.py new file mode 100644 index 0000000..fe64fb6 --- /dev/null +++ b/modules/role/files/cryptoportfolio/slack-notify.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import sys +import json +import urllib3 + +project = sys.argv[1] +url = sys.argv[2] +version = sys.argv[3] + +def post(url, data): + urllib3.disable_warnings() + http = urllib3.PoolManager() + + encoded = data.encode('utf-8') + + r = http.request("POST", url, + headers={'Content-Type': 'application/json'}, + body=encoded) + +data = { + "icon_url": "https://learn.puppet.com/static/images/logos/Puppet-Logo-Mark-Amber.png", + "text": "Deployed {} on {}".format(version, project), + } + +json_data = json.dumps(data) +post(url, json_data) -- cgit v1.2.3