From e5824080d8e1de22cca53ff6db52d03be7bc3dce Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 19 Feb 2019 11:20:25 -0800 Subject: [PATCH] Switch artifact return back to list This is a partial revert of f12453f6cbb452451bcce0cef9c4da4b957fd4a5. 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 --- doc/source/user/jobs.rst | 6 ++--- .../artifact-format-2de4b9c038e28115.yaml | 8 ------- zuul/lib/artifacts.py | 22 +++++-------------- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/doc/source/user/jobs.rst b/doc/source/user/jobs.rst index 19bf4ea822..90dceab707 100644 --- a/doc/source/user/jobs.rst +++ b/doc/source/user/jobs.rst @@ -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 diff --git a/releasenotes/notes/artifact-format-2de4b9c038e28115.yaml b/releasenotes/notes/artifact-format-2de4b9c038e28115.yaml index 91c90ef0e6..0bfa1654fb 100644 --- a/releasenotes/notes/artifact-format-2de4b9c038e28115.yaml +++ b/releasenotes/notes/artifact-format-2de4b9c038e28115.yaml @@ -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. diff --git a/zuul/lib/artifacts.py b/zuul/lib/artifacts.py index 81a83386f7..592a7fc4fb 100644 --- a/zuul/lib/artifacts.py +++ b/zuul/lib/artifacts.py @@ -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: