zuul-jobs/roles/promote-docker-image/tasks/promote-cleanup.yaml
Jean-Philippe Evrard 9bc813daa7 Dockerhub now returns 200 for DELETEs
We need to adapt to this, else the promote pipeline fails.

Change-Id: Ie617efc8b9a7fefb565c67c796d42c87a1ee998f
2019-06-20 10:20:40 +00:00

21 lines
813 B
YAML

- name: List tags
uri:
url: "https://hub.docker.com/v2/repositories/{{ image.repository }}/tags?page_size=1000"
status_code: 200
register: tags
- name: Set cutoff timestamp to 24 hours ago
command: "python3 -c \"import datetime; print((datetime.datetime.utcnow()-datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M:%fZ'))\""
register: cutoff
- name: Delete all change tags older than the cutoff
no_log: true
loop: "{{ tags.json.results }}"
loop_control:
loop_var: docker_tag
when: docker_tag.last_updated < cutoff.stdout and docker_tag.name.startswith('change_')
uri:
url: "https://hub.docker.com/v2/repositories/{{ image.repository }}/tags/{{ docker_tag.name }}/"
method: DELETE
status_code: [200,204]
headers:
Authorization: "JWT {{ jwt_token.json.token }}"