From 7d43e0237cb1dacbbf576d29fc45113a0edd8dd8 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 23 Jul 2019 20:02:40 +0300 Subject: Add: deploy upon success --- api.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/api.py b/api.py index 81f644e..beae910 100755 --- a/api.py +++ b/api.py @@ -472,7 +472,27 @@ class Controller(API): name = r.get('name') logging.info('Repository %s build status %s', name, status) self._builds[name] = status + if status == 'success': + self._deploy(name) + def _deploy(self, name): + spec = { + 'artifact_id': name, + 'published_name': name, + } + + url = '{}/updaterepo'.format(self.DEPLOYER) + argv = [ + 'curl', + '-HAuthorization: Bearer {}'.format(self._token), + '-HContent-Type: application/json', + '--data-binary', json.dumps(spec), + url, + ] + ok = runcmd('.', argv, self.MAX_TRIGGER_TIME) + if not ok: + raise bottle.HTTPError(500, 'Error deploying') + return 'Deployed\n' def runcmd(cwd, argv, timeout): -- cgit v1.2.1