zuul-jobs/roles/push-to-intermediate-registry/tasks/push-image.yaml
Albin Vass d0e2016592 Add loop var policy to ansible-lint
This adds a custom ansible-lint rule at .rules/ZuulJobsNamespaceLoopVar.py
that enforces the loop var policy described at:
https://zuul-ci.org/docs/zuul-jobs/policy.html#ansible-loops-in-roles

It also updates existing roles to follow the policy.

Change-Id: I92b2ff56a1c2702542fc07b316f1809087a4c92f
2020-04-29 17:20:59 +02:00

31 lines
1.3 KiB
YAML

# To support usage with both docker and podman, the buildset registry
# keeps "docker.io" entries un-namespaced, and any other namespaces
# are namespaced. Therefore, if we see docker.io in the repository
# name, we strip it here.
- name: Push tag to intermediate registry
command: >-
skopeo --insecure-policy copy
docker://127.0.0.1:{{ socat_port }}/{{ image.repository | regex_replace('^docker\.io/(.*)', '\1') }}:{{ zj_image_tag }}
docker://{{ intermediate_registry.host | ipwrap }}:{{ intermediate_registry.port }}/{{ image.repository }}:{{ zuul.build }}_{{ zj_image_tag }}
retries: 3
register: result
until: result is success
loop: "{{ image.tags | default(['latest']) }}"
loop_control:
loop_var: zj_image_tag
- name: Return artifact to Zuul
zuul_return:
data:
zuul:
artifacts:
- name: "{{ image.repository }}:{{ zj_image_tag }}"
url: "docker://{{ intermediate_registry.host | ipwrap }}:{{ intermediate_registry.port }}/{{ image.repository }}:{{ zuul.build }}_{{ zj_image_tag }}"
metadata:
type: container_image
repository: "{{ image.repository }}"
tag: "{{ zj_image_tag }}"
loop: "{{ image.tags | default(['latest']) }}"
loop_control:
loop_var: zj_image_tag