-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrigger_rollback.py
executable file
·39 lines (32 loc) · 1.14 KB
/
trigger_rollback.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python2
import sys
import json
import argparse
import requests
from functools import partial
from sign_payload import sign
from lib.settings_loader import settings
def err(msg):
sys.stderr.write(msg + '\n')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Triggers the rollback process')
parser.add_argument('host', help='The host')
parser.add_argument('repo', help='The repository to deploy')
parser.add_argument('--port', help='The port', default='4567')
parser.add_argument('--branch', help='The branch', default='master')
parser.add_argument('--tag', help='The tag to rollback')
args = parser.parse_args()
payload = json.dumps({
"repo": args.repo,
"ref" : args.branch,
})
try:
r = requests.post('http://{host}:{port}/rollback'.format(
host = args.host,
port = args.port,
), headers={
'X-Hub-Signature': 'sha1='+sign(payload)
}, data=payload)
print(r.text)
except requests.exceptions.ConnectionError:
print('Deploy server {} at port {} is not running'.format(args.host, args.port))