Add change message to Zuul vars in inventory

Having the change message available via the Zuul vars simplifies cases
where a job e.g. needs to update a GitHub/Jira/... ticket.

Those ticket numbers are usually referenced in the commit/PR message.

This avoids having to deal with secrets etc. to get this information
'out-of-band'.

Change-Id: Ib88db7f724dadfb8a4f86e76692f3e1c2c63a258
This commit is contained in:
Simon Westphahl 2019-01-15 11:22:40 +01:00
parent 1779565108
commit 5b4c5299ad
3 changed files with 7 additions and 0 deletions

View File

@ -525,6 +525,10 @@ are available:
E.g., `https://review.example.org/#/c/123456/` or
`https://github.com/example/example/pull/1234`.
.. var:: message
The commit or pull request message of the change.
Branch Items
~~~~~~~~~~~~

View File

@ -60,6 +60,7 @@ class TestInventory(TestInventoryBase):
self.assertIn('src_root', z_vars['executor'])
self.assertIn('job', z_vars)
self.assertEqual(z_vars['job'], 'single-inventory')
self.assertEqual(z_vars['message'], 'A')
self.executor_server.release()
self.waitUntilSettled()

View File

@ -175,6 +175,8 @@ class ExecutorClient(object):
zuul_params['change_url'] = item.change.url
if hasattr(item.change, 'patchset'):
zuul_params['patchset'] = str(item.change.patchset)
if hasattr(item.change, 'message'):
zuul_params['message'] = item.change.message
if (hasattr(item.change, 'oldrev') and item.change.oldrev
and item.change.oldrev != '0' * 40):
zuul_params['oldrev'] = item.change.oldrev