Allow upload-docker-image role to be used outside of promote

This adds an option to the upload-docker-image role so that a job
can be written to run build-docker-image and upload-docker-image
in a release pipeline.  This lets users build tagged docker images
from release tags rather than using the promote pipeline (which
may have built the image before a release git tag was applied).

Change-Id: Id28d0a85e02e56640911c44ddbfff7b38547b0b4
This commit is contained in:
James E. Blair 2020-06-10 09:53:31 -07:00
parent 8748c9add2
commit bf43f5bb8c
3 changed files with 12 additions and 1 deletions

View File

@ -1,3 +1,13 @@
Upload one or more docker images.
.. include:: ../../roles/build-docker-image/common.rst
.. zuul:rolevar:: upload_docker_image_promote
:type: bool
:default: true
If ``true`` (the default), then this role will upload the image(s)
to Docker Hub with special tags designed for use by the
:zuul:role:`promote-docker-image` role. Set to ``false`` to use
this role to directly upload images with the final tag (e.g., as
part of an un-gated release job).

View File

@ -1,2 +1,3 @@
zuul_work_dir: "{{ zuul.project.src_dir }}"
docker_dockerfile: "Dockerfile"
upload_docker_image_promote: true

View File

@ -1,5 +1,5 @@
- name: Upload tag to dockerhub
command: "docker push {{ zj_image.repository }}:change_{{ zuul.change }}_{{ zj_image_tag }}"
command: "docker push {{ zj_image.repository }}:{{ upload_docker_image_promote | ternary('change_' + zuul.change + '_', '') }}{{ zj_image_tag }}"
loop: "{{ zj_image.tags | default(['latest']) }}"
loop_control:
loop_var: zj_image_tag