]>
Commit | Line | Data |
---|---|---|
a4c92ff7 IB |
1 | #!/usr/bin/env python3 |
2 | ||
bd263a98 | 3 | import os |
a4c92ff7 IB |
4 | import sys |
5 | import json | |
6 | import urllib3 | |
7 | ||
bd263a98 IB |
8 | project = os.environ["P_PROJECT"] |
9 | url = os.environ["P_WEBHOOK"] | |
10 | version = os.environ["P_VERSION"] | |
11 | host = os.environ["P_HOST"] | |
12 | if os.environ["P_HTTPS"] == "true": | |
13 | scheme = "https://" | |
14 | else: | |
15 | scheme = "http://" | |
a4c92ff7 IB |
16 | |
17 | def post(url, data): | |
18 | urllib3.disable_warnings() | |
19 | http = urllib3.PoolManager() | |
20 | ||
21 | encoded = data.encode('utf-8') | |
22 | ||
23 | r = http.request("POST", url, | |
24 | headers={'Content-Type': 'application/json'}, | |
25 | body=encoded) | |
26 | ||
27 | data = { | |
50812570 | 28 | "username": "Puppet", |
a4c92ff7 | 29 | "icon_url": "https://learn.puppet.com/static/images/logos/Puppet-Logo-Mark-Amber.png", |
bd263a98 IB |
30 | "text": "Deployed {} of {} on {}{}".format( |
31 | version, | |
32 | project, | |
33 | scheme, | |
34 | host, | |
35 | ), | |
a4c92ff7 IB |
36 | } |
37 | ||
38 | json_data = json.dumps(data) | |
39 | post(url, json_data) |