Always report the status url in Gerrit checks

When using the Gerrit checks API, we only included a URL when the
build completed.  However, we can also supply the URL while the
build is in progress.  This will (at least until we start recording
in-progress buildsets in the database) be the change-specific status
page.

Change-Id: I3202764683b57c19df25169c2b47bc9561df0e93
This commit is contained in:
James E. Blair 2020-06-26 19:13:30 -07:00
parent eec7b303fb
commit 3472114a67
3 changed files with 20 additions and 3 deletions

View File

@ -14,6 +14,9 @@ git_dir=/tmp/zuul-test/merger-git
git_user_email=zuul@example.com
git_user_name=zuul
[web]
root=http://zuul.example.com
[executor]
git_dir=/tmp/zuul-test/executor-git

View File

@ -306,13 +306,27 @@ class TestChecksApi(ZuulTestCase):
self.assertEqual(A.checks_history[0]['zuul:check']['state'],
'NOT_STARTED')
self.assertEqual(A.checks_history[1]['zuul:check']['state'],
'SCHEDULED')
self.assertEqual(
A.checks_history[1]['zuul:check']['url'],
'http://zuul.example.com/t/tenant-one/status/change/2,1')
self.assertEqual(A.checks_history[2]['zuul:check']['state'],
'RUNNING')
self.assertEqual(
A.checks_history[2]['zuul:check']['url'],
'http://zuul.example.com/t/tenant-one/status/change/2,1')
self.assertEqual(A.checks_history[3]['zuul:check']['state'],
'SUCCESSFUL')
self.assertTrue(
A.checks_history[3]['zuul:check']['url'].startswith(
'http://zuul.example.com/t/tenant-one/buildset/'))
self.assertEqual(len(A.checks_history), 4)
self.assertTrue(isinstance(
A.checks_history[3]['zuul:check']['started'], str))
self.assertTrue(isinstance(

View File

@ -1071,9 +1071,9 @@ class GerritConnection(BaseConnection):
checkinfo['started'] = fmt(item.enqueue_time)
if item.report_time:
checkinfo['finished'] = fmt(item.report_time)
url = item.formatStatusUrl()
if url:
checkinfo['url'] = url
url = item.formatStatusUrl()
if url:
checkinfo['url'] = url
if checkinfo:
for x in range(1, 4):
try: