Add links to change pages on /zuul/status page.
The links to Jenkins job pages on the /zuul/status page are awesome,
but now we need links to go the other direction and link back to
Gerrit. Add links using the event['change']['url'] parameter as the
target.
Change-Id: I24f189fd0d14e59e0ae5484b15ea6e3aa899e62f
diff --git a/zuul/model.py b/zuul/model.py
index e4ab133..9d49efb 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -155,6 +155,7 @@
self.project = project
self.branch = None
self.number = None
+ self.url = None
self.patchset = None
self.refspec = None
self.ref = None
@@ -164,6 +165,7 @@
if event.change_number:
self.branch = event.branch
self.number = event.change_number
+ self.url = event.change_url
self.patchset = event.patch_number
self.refspec = event.refspec
if event.ref:
@@ -196,9 +198,15 @@
def formatStatus(self, indent=0, html=False):
indent_str = ' ' * indent
ret = ''
- ret += '%sProject %s change %s\n' % (indent_str,
- self.project.name,
- self._id())
+ if html and self.url is not None:
+ ret += '%sProject %s change <a href="%s">%s</a>\n' % (indent_str,
+ self.project.name,
+ self.url,
+ self._id())
+ else:
+ ret += '%sProject %s change %s\n' % (indent_str,
+ self.project.name,
+ self._id())
for job in self.project.getJobs(self.queue_name):
result = self.jobs.get(job.name)
job_name = job.name
@@ -298,6 +306,7 @@
self.project_name = None
# patchset-created, comment-added, etc.
self.change_number = None
+ self.change_url = None
self.patch_number = None
self.refspec = None
self.approvals = []
diff --git a/zuul/trigger/gerrit.py b/zuul/trigger/gerrit.py
index 56aa1ee..2d2e778 100644
--- a/zuul/trigger/gerrit.py
+++ b/zuul/trigger/gerrit.py
@@ -37,6 +37,7 @@
event.project_name = change.get('project')
event.branch = change.get('branch')
event.change_number = change.get('number')
+ event.change_url = change.get('url')
patchset = data.get('patchSet')
if patchset:
event.patch_number = patchset.get('number')