Merge "Report topic to jobs as zuul.topic"

This commit is contained in:
Zuul 2024-03-12 22:38:31 +00:00 committed by Gerrit Code Review
commit da07d5ff5e
4 changed files with 14 additions and 1 deletions

View File

@ -808,6 +808,10 @@ are available:
jobs. It is included here to support interfacing with systems
that identify a change by the commit.
.. var:: topic
The topic of the change (if any)
Branch Items
~~~~~~~~~~~~

View File

@ -0,0 +1,5 @@
---
features:
- |
The topic of a change (if any) is now reported in the :var:`zuul.topic`
job variable

View File

@ -1183,7 +1183,8 @@ class TestGerritDriver(ZuulTestCase):
@simple_layout('layouts/simple.yaml')
def test_change_event(self):
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
topic='test-topic')
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
@ -1203,6 +1204,7 @@ class TestGerritDriver(ZuulTestCase):
self.assertEqual(zuulvars["message"], strings.b64encode('A'))
self.assertEqual(1, len(self.history))
self.assertEqual(1, len(A.messages))
self.assertEqual('test-topic', zuulvars['topic'])
@simple_layout('layouts/simple.yaml')
def test_tag_event(self):

View File

@ -67,6 +67,8 @@ def construct_build_params(uuid, connections, job, item, pipeline,
if hasattr(change, 'message'):
zuul_params['message'] = strings.b64encode(change.message)
zuul_params['change_message'] = change.message
if hasattr(change, 'topic'):
zuul_params['topic'] = change.topic
commit_id = None
if (hasattr(change, 'oldrev') and change.oldrev
and change.oldrev != '0' * 40):