mirror of
https://github.com/gryf/ferrit.git
synced 2026-02-07 16:55:47 +01:00
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).
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
import bottle
|
|
|
|
|
|
@bottle.route('/plugins/events-log/')
|
|
def events_log(params=None):
|
|
return ''
|
|
|
|
|
|
@bottle.route('/a/projects/')
|
|
def projects(params=None):
|
|
"""
|
|
Possible params (accessible via bottle.request.params) is 'd'
|
|
"""
|
|
return {"All-Projects": {"id": "All-Projects",
|
|
"description": "all projects",
|
|
"state": "ACTIVE",
|
|
"web_links": [{"name": "browse",
|
|
"url":
|
|
"/plugins/gitiles/All-Projects",
|
|
"target": "_blank"}]},
|
|
"All-Users": {"id": "All-Users",
|
|
"description": "users",
|
|
"state": "ACTIVE",
|
|
"web_links": [{"name": "browse",
|
|
"url": "/plugins/gitiles/All-Users",
|
|
"target": "_blank"}]},
|
|
"DEDICATED": {"id": "DEDICATED",
|
|
"state": "ACTIVE",
|
|
"web_links": [{"name": "browse",
|
|
"url": "/plugins/gitiles/DEDICATED",
|
|
"target": "_blank"}]}}
|
|
|
|
|
|
@bottle.post('/a/changes/<project>~<branch>~<id>/revisions/<commit_id>/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/')
|
|
def events(t1=None):
|
|
return {}
|
|
|
|
|
|
bottle.run(host='localhost', port=8181, debug=True)
|