Add Item.formatStatusUrl

This method can be used by reporters to generate the best "status"
url to report for an item.  It will report the buildset page if
that is available, or the per-change status page if it is not.

Eventually we plan on making the database required, at which point
we can insert buildsets in the db earlier.  Then we can report the
buildset page in all cases.  By beginning to use this method now,
we can seamlessly upgrade reporters in the future.

Test coverage for this is added in change
Ida0cdef682ca2ce117617eacfb67f371426a3131.

Change-Id: Ib0c2ca84f6c4d30f233382048c8885fb73edfeec
This commit is contained in:
James E. Blair 2019-09-10 11:09:40 -07:00
parent 864bfc1d16
commit 48aa3ebd98
1 changed files with 21 additions and 0 deletions

View File

@ -2688,6 +2688,27 @@ class QueueItem(object):
else:
return self.formatProvisionalJobResult(job)
def formatStatusUrl(self):
if self.current_build_set.result:
# We have reported (or are reporting) and so we should
# send the buildset page url
if (self.pipeline.tenant.report_build_page and
self.pipeline.tenant.web_root):
pattern = urllib.parse.urljoin(self.pipeline.tenant.web_root,
'buildset/{buildset.uuid}')
return self.formatUrlPattern(pattern)
# We haven't reported yet (or we don't have a database), so
# the best we can do at the moment is send the status page
# url. TODO: require a database, insert buildsets into it
# when they are created, and remove this case.
if self.pipeline.tenant.web_root:
pattern = urllib.parse.urljoin(
self.pipeline.tenant.web_root,
'status/change/{change.number},{change.patchset}')
return self.formatUrlPattern(pattern)
# Apparently we have no web site.
return None
def formatProvisionalJobResult(self, job):
build = self.current_build_set.getBuild(job.name)
result = build.result