Add build set URL to reporter

formatStatusUrl() return build set URL when the
item.current_build_set.result exist (zuul/model.py)

Also updated the quick-start to continue to look for the
build URL instead of the buildset URL.

Change-Id: I5f8433e2926da5a8d14b966d89cc943be1ecfca9
This commit is contained in:
Kenny Ho 2022-04-08 18:26:30 +00:00
parent 895bb36467
commit 8176fd2ffb
4 changed files with 17 additions and 1 deletions

View File

@ -84,7 +84,7 @@
- name: Find the build URL with regex - name: Find the build URL with regex
set_fact: set_fact:
build_url: "{{ result_json | to_json | from_json | json_query(json_query_log_url) | regex_search('(http://[^ ]*)') }}" build_url: "{{ result_json | to_json | from_json | json_query(json_query_log_url) | regex_search('-.*(http://[^ ]*)') | regex_search('(http://[^ ]*)') }}"
vars: vars:
json_query_log_url: "messages[?contains(@.message, 'http://')].message | [1]" json_query_log_url: "messages[?contains(@.message, 'http://')].message | [1]"

View File

@ -0,0 +1,5 @@
---
features:
- |
Added build set url to Zuul comment. This provide a quick way
for user to reach the build set page from Gerrit.

View File

@ -26,6 +26,7 @@ from collections import namedtuple
from unittest import mock, skip from unittest import mock, skip
from uuid import uuid4 from uuid import uuid4
from kazoo.exceptions import NoNodeError from kazoo.exceptions import NoNodeError
from testtools.matchers import StartsWith
import git import git
import fixtures import fixtures
@ -365,6 +366,10 @@ class TestScheduler(ZuulTestCase):
'label1') 'label1')
self.assertEqual(self.getJobFromHistory('project-test2').node, self.assertEqual(self.getJobFromHistory('project-test2').node,
'label1') 'label1')
self.assertThat(A.messages[1],
StartsWith(
'Build succeeded (gate).\n'
'https://zuul.example.com/t/tenant-one/buildset'))
# TODOv3(jeblair): we may want to report stats by tenant (also?). # TODOv3(jeblair): we may want to report stats by tenant (also?).
# Per-driver # Per-driver

View File

@ -172,6 +172,9 @@ class BaseReporter(object, metaclass=abc.ABCMeta):
def _formatItemReportSuccess(self, item, with_jobs=True): def _formatItemReportSuccess(self, item, with_jobs=True):
msg = item.pipeline.success_message msg = item.pipeline.success_message
if with_jobs: if with_jobs:
status_url = item.formatStatusUrl()
if status_url is not None:
msg += '\n' + status_url
msg += '\n\n' + self._formatItemReportJobs(item) msg += '\n\n' + self._formatItemReportJobs(item)
return msg return msg
@ -196,6 +199,9 @@ class BaseReporter(object, metaclass=abc.ABCMeta):
else: else:
msg = item.pipeline.failure_message msg = item.pipeline.failure_message
if with_jobs: if with_jobs:
status_url = item.formatStatusUrl()
if status_url is not None:
msg += '\n' + status_url
msg += '\n\n' + self._formatItemReportJobs(item) msg += '\n\n' + self._formatItemReportJobs(item)
return msg return msg