coverage: Pick the latest coverage report from the current project
In Ansible, `get_url`, when invoked like this code did, won't keep
overwriting the target file. This means that when the job runs in a
queue with a long history of artifacts, the oldest one wins instead of
the newest one.
I don't think I could filter-first index-later when using Ansible's
`when` construct, so switch to JSON queries.
While I'm at this, I really want to see some debug info, so let's add a
`debug` in there -- and that requires splitting out into an extra task
as far as I "know" Ansible.
Change-Id: I3b53d062dae5b746c9847ddf85fd749f72387df4
diff --git a/roles/pycobertura-diff/tasks/main.yaml b/roles/pycobertura-diff/tasks/main.yaml
index 444d525..5c80870 100644
--- a/roles/pycobertura-diff/tasks/main.yaml
+++ b/roles/pycobertura-diff/tasks/main.yaml
@@ -9,14 +9,12 @@
chdir: "{{ zuul.project.src_dir }}"
- name: Retrieve coverage from parent jobs
- get_url:
- url: "{{ item.url }}"
- dest: "{{ new_source_prefix }}/coverage.xml"
- when:
- - item.metadata is defined
- - item.metadata.type is defined
- - item.metadata.type == "cobertura_xml"
- loop: "{{ zuul.artifacts }}"
+ include_task: download.yaml
+ loop: "{{ zuul.artifacts | json_query(artifact_seletctor) }}"
+ vars:
+ artifact_seletctor: "[([?metadata.type == 'cobertura_xml' && project == '{{ zuul.project.name }}'])[-1]]"
+ loop_control:
+ loop_var: artifact
- name: Generate pycobertura report
shell: |