ef47a743b6
Use '{{ zuul.pipeline }}' tag prefix in *-docker-image instead of 'change_{{ zuul.change }}' one when zuul.change is not provided, that is the case with periodic jobs. This allows to build, upload and promote images using periodic jobs e.g: - project: periodic: - project-buildset-registry - project-build-image1: dependencies: - name: project-buildset-registry - project-build-image2: dependencies: - name: project-buildset-registry # pulls from buildset registry and tests both images - project-test: dependencies: - name: project-build-image1 - name: project-build-image2 # pre-pulls images from buildset registry for fast build - project-upload-image1: dependencies: - name: project-test - project-upload-image2: dependencies: - name: project-test - project-promote: dependencies: - name: project-upload-image1 - name: project-upload-image2 This fuctionality will allow to keep latest images up to date for the case when image incorporates continuously updating code from multiple repositories. Using true ternary for tag evaluation because ternary filter requires all passed to it variables be defined or defaulted [0]. [0] https://github.com/ansible/ansible/issues/51276 Change-Id: I8eb7d2baa24905e7aac51fce0b2f9b1f24f037f9 Signed-off-by: Andrii Ostapenko <andrii.ostapenko@att.com>
42 lines
1.7 KiB
YAML
42 lines
1.7 KiB
YAML
- name: Set up siblings
|
|
include_tasks: siblings.yaml
|
|
|
|
- name: Upload tag to dockerhub
|
|
vars:
|
|
promote_tag_prefix: "{{ ('change_' + zuul.change) if (zuul.change is defined) else zuul.pipeline }}_"
|
|
# docker buildx doesn't have a separate push command, only the
|
|
# ability to push at the end of a build. We run build here with
|
|
# all the same arguments as in the buildx build tasks, so they
|
|
# should result in a noop build and just a push.
|
|
command: >-
|
|
docker buildx build {{ zj_image.path | default('.') }} -f {{ zj_image.dockerfile | default(docker_dockerfile) }}
|
|
{% if zj_image.target | default(false) -%}
|
|
--target {{ zj_image.target }}
|
|
{% endif -%}
|
|
{% for build_arg in zj_image.build_args | default([]) -%}
|
|
--build-arg {{ build_arg }}
|
|
{% endfor -%}
|
|
{% if zj_image.siblings | default(false) -%}
|
|
--build-arg "ZUUL_SIBLINGS={{ zj_image.siblings | join(' ') }}"
|
|
{% endif -%}
|
|
{% for tag in zj_image.tags | default(['latest']) -%}
|
|
--tag {{ docker_registry | ternary(docker_registry + '/', '') }}{{ zj_image.repository }}:{{ upload_docker_image_promote | ternary(promote_tag_prefix, '') }}{{ tag }}
|
|
{% endfor -%}
|
|
{% for label in zj_image.labels | default([]) -%}
|
|
--label "{{ label }}"
|
|
{% endfor %}
|
|
{% if zuul.change | default(false) %}
|
|
--label "org.zuul-ci.change={{ zuul.change }}"
|
|
{% endif %}
|
|
--label "org.zuul-ci.change_url={{ zuul.change_url }}"
|
|
--platform={{ zj_image.arch | join(',') }}
|
|
--push
|
|
args:
|
|
chdir: "{{ zuul_work_dir }}/{{ zj_image.context }}"
|
|
environment:
|
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
|
register: result
|
|
until: result.rc == 0
|
|
retries: 3
|
|
delay: 30
|