zuul-jobs/roles/promote-docker-image/tasks/main.yaml
James E. Blair 61a76f95f0 Add retries to promote-docker-image
This should make this step more robust to remote failures.

Change-Id: I3f3d643ac5285027bda909ac6d55d8959a4b4f79
2019-03-20 09:02:18 -07:00

31 lines
908 B
YAML

- name: Verify repository names
when: |
docker_credentials.repository is defined
and not item.repository | regex_search(docker_credentials.repository)
loop: "{{ docker_images }}"
fail:
msg: "{{ item.repository }} not permitted by {{ docker_credentials.repository }}"
# This is used by the delete tasks
- name: Get dockerhub JWT token
no_log: true
uri:
url: "https://hub.docker.com/v2/users/login/"
body_format: json
body:
username: "{{ docker_credentials.username }}"
password: "{{ docker_credentials.password }}"
register: jwt_token
delay: 5
retries: 3
until: jwt_token and jwt_token.status==200
- name: Promote image
loop: "{{ docker_images }}"
loop_control:
loop_var: image
include_tasks: promote-retag.yaml
- name: Delete obsolete tags
loop: "{{ docker_images }}"
loop_control:
loop_var: image
include_tasks: promote-cleanup.yaml