From 9605cb22f09781ef9ea9b36eca18686aa0b3fe9c Mon Sep 17 00:00:00 2001 From: gryf Date: Sun, 27 Oct 2019 17:42:36 +0100 Subject: [PATCH] Implement method /a/changes. After gerrit recives an action (like creating a review, comment, and so on) it will send appropriate json from ssh server. Jenkins, which is listening on the ssh channel will receive this message and do appropriate action (for example, it will do the build/test whatever), and sends back notification back to HTTP gerrit server to /a/changes endpoint. There are couple of requests to that url, which will indicate what jenkins is doing (like starting build, sending result info). --- gerrit_fake_http_server.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gerrit_fake_http_server.py b/gerrit_fake_http_server.py index cc5e9e2..b29435e 100644 --- a/gerrit_fake_http_server.py +++ b/gerrit_fake_http_server.py @@ -31,11 +31,19 @@ def projects(params=None): "target": "_blank"}]}} -@bottle.post('/a/changes') -def changes(param=None): - print(param) - print(bottle.request.json) - pass +@bottle.post('/a/changes/~~/revisions//review') +def changes(project, branch, id, commit_id): + # We are looking for labels in the json + labels = bottle.request.json.get('labels', {}) + if not labels: + return + + # TODO(gryf): It's on gerrit side now. What we do with this information on + # Ferrit? Verified is either 1 or -1, which indicates build in jenkins + if labels.get('Verified') == 1: + return True + else: + return False @bottle.route('/a/plugins/events-log/events/')