Browse Source

Switch artifact return back to list

This is a partial revert of f12453f6cb.

The use case that change was designed to address is poorly served by
that change.  The intent was to make it easier to return multiple
artifacts in multiple playbooks independently by relying on the dictionary
merge behavior of zuul_return.  However, in the entirely likely case
of artifacts with generated names, it becomes difficult because Ansible
does not run jinja on dictionary keys.

Therefore, revert to the previous list behavior.  A subsequent change
will add a feature to zuul_return to address the underlying issue of
returning multiple artifacts from different playbooks.

Change-Id: I0581aa68fcef320ab27c11ddd6338a15eef38ceb
changes/79/637979/1
James E. Blair 2 years ago
parent
commit
e5824080d8
3 changed files with 9 additions and 27 deletions
  1. +3
    -3
      doc/source/user/jobs.rst
  2. +0
    -8
      releasenotes/notes/artifact-format-2de4b9c038e28115.yaml
  3. +6
    -16
      zuul/lib/artifacts.py

+ 3
- 3
doc/source/user/jobs.rst View File

@ -229,7 +229,7 @@ of item.
under the ``zuul`` key:
.. var:: artifacts
:type: dict
:type: list
If the job has a :attr:`job.requires` attribute, and Zuul has
found changes ahead of this change in the pipeline with matching
@ -795,11 +795,11 @@ under the **zuul.artifacts** dictionary. For example:
data:
zuul:
artifacts:
tarball:
- name: tarball
url: http://example.com/path/to/package.tar.gz
metadata:
version: 3.0
docs:
- name: docs:
url: build/docs/
If the value of **url** is a relative URL, it will be combined with


+ 0
- 8
releasenotes/notes/artifact-format-2de4b9c038e28115.yaml View File

@ -2,11 +2,3 @@
features:
- Artifacts may now include a metadata field for storing arbitrary
metadata about the artifacts in the SQL database.
deprecations:
- Artifacts should now be supplied to zuul_return in dictionary form
instead of a list. See :ref:`return_artifacts`.
This is to aid in multiple playbooks providing information back to
Zuul without requiring coordination with each other.
Support for the list format will be removed in a future version.

+ 6
- 16
zuul/lib/artifacts.py View File

@ -15,20 +15,16 @@
import voluptuous as v
import urllib.parse
old_artifact = {
'name': str,
'url': str,
}
new_artifact = {
'url': str,
artifact = {
'name': v.Required(str),
'url': v.Required(str),
'metadata': dict,
}
zuul_data = {
'zuul': {
'log_url': str,
'artifacts': v.Any([old_artifact], {str: new_artifact}),
'artifacts': [artifact],
v.Extra: object,
}
}
@ -48,18 +44,13 @@ def get_artifacts_from_result_data(result_data, logger=None):
ret = []
if validate_artifact_schema(result_data):
artifacts = result_data.get('zuul', {}).get(
'artifacts', {})
if isinstance(artifacts, list):
new_artifacts = {}
for a in artifacts:
new_artifacts[a['name']] = {'url': a['url']}
artifacts = new_artifacts
'artifacts', [])
default_url = result_data.get('zuul', {}).get(
'log_url')
if default_url:
if default_url[-1] != '/':
default_url += '/'
for artifact_name, artifact in artifacts.items():
for artifact in artifacts:
url = artifact['url']
if default_url:
# If the artifact url is relative, it will be combined
@ -72,7 +63,6 @@ def get_artifacts_from_result_data(result_data, logger=None):
logger.debug("Error parsing URL:",
exc_info=1)
d = artifact.copy()
d['name'] = artifact_name
d['url'] = url
ret.append(d)
else:


Loading…
Cancel
Save