Merge "Add zuul.items to job vars" into feature/zuulv3

This commit is contained in:
Jenkins 2017-07-21 03:51:34 +00:00 committed by Gerrit Code Review
commit 0da8b091ff
2 changed files with 36 additions and 3 deletions

View File

@ -171,11 +171,30 @@ All items provide the following information as Ansible variables:
job for reporting or classification purposes.
**zuul.items**
A data structure representing the items being tested with this
change.
.. TODO: implement and document items
A list of dictionaries, each representing an item being tested with
this change with the format:
**project.name**
The name of the project, excluding hostname. E.g., `org/project`.
**project.canonical_hostname**
The canonical hostname where the project lives. E.g.,
`git.example.com`.
**project.canonical_name**
The full canonical name of the project including hostname. E.g.,
`git.example.com/org/project`.
**branch**
The target branch of the change (without the `refs/heads/` prefix).
**change**
The identifier for the change.
**patchset**
The patchset identifier for the change. If a change is revised,
this will have a different value.
Change Items
++++++++++++

View File

@ -175,6 +175,20 @@ class ExecutorClient(object):
zuul_params['oldrev'] = item.change.oldrev
if hasattr(item.change, 'newrev'):
zuul_params['newrev'] = item.change.newrev
zuul_params['items'] = []
for i in all_items:
d = dict()
d['project'] = dict(
name=i.change.project.name,
canonical_hostname=i.change.project.canonical_hostname,
canonical_name=i.change.project.canonical_name)
if hasattr(i.change, 'number'):
d['change'] = i.change.number
if hasattr(i.change, 'patchset'):
d['patchset'] = i.change.number
if hasattr(i.change, 'branch'):
d['branch'] = i.change.branch
zuul_params['items'].append(d)
# Legacy environment variables
params = dict(ZUUL_UUID=uuid,