Adds retag with version hash for periodic container builds

For the periodic jobs once we build containers and push to rdo
registry we also need to tag the images with the delorean repo
hash

This switches the current tagging so we instead tag during build
using the version-hash and then tag with tripleo-ci-testing
when its periodic

Testing at https://review.rdoproject.org/r/#/c/19131/

Change-Id: I727e748eee641e12cede74773497dce49fcb317c
This commit is contained in:
Marios Andreou 2019-03-06 15:00:03 +02:00
parent b8df3435ea
commit 0f61e33f01
3 changed files with 41 additions and 1 deletions

View File

@ -12,6 +12,16 @@
push_tag: "{{ push_tag | default('latest') }}"
push_containers: "{{ push_containers | default(false) | bool }}"
- name: Get contents of delorean repo baseurl for the version hash
become: true
shell: >
cat /etc/yum.repos.d/delorean.repo |awk -F= '/baseurl/ {print $2}'
register: baseurl
- name: Set version_hash fact
set_fact:
version_hash: "{{ baseurl.stdout.split('/')[-1] }}"
- name: grab kolla patch if needed
when: ansible_pkg_mgr == "dnf"
shell: |
@ -72,3 +82,22 @@
> {{ workspace }}/build.log 2> {{ workspace }}/build-err.log
RESULT=$?
exit $RESULT
- name: Retrieve the images by version_hash and retag with tripleo-ci-testing if periodic
when:
- zuul is defined
- "'periodic' in zuul.pipeline"
block:
- name: Retrieve list of built images
shell: >
docker images --format "{{ '{{' }}.Repository{{ '}}' }}" \
--filter "reference=*:{{ version_hash }}"
register: built_images
- name: Tag images
vars:
image: "{{ item }}"
include: tag.yml
static: no
with_items: "{{ built_images.stdout_lines }}"

View File

@ -0,0 +1,11 @@
---
- block:
# Tag and push in the same task for the sake of doing less tasks
- name: "Tag image: {{ image }}"
command: >
{{ cmd }}
with_items:
- "docker tag {{ image }}:{{ version_hash }} {{ image }}:{{ push_tag }}"
- "docker push {{ image }}:{{ push_tag }}"
loop_control:
loop_var: "cmd"

View File

@ -2,7 +2,7 @@
base={{ ansible_distribution|lower }}
type=binary
registry={{ push_registry }}
tag={{ push_tag }}
tag={{ version_hash }}
template_override={{ openstack_git_root }}/tripleo-common/container-images/tripleo_kolla_template_overrides.j2
# we use the repos off the main host as they will already have the correct mirror info in them
rpm_setup_config=http://172.17.0.1/delorean.repo,http://172.17.0.1/delorean-{{ ci_branch }}-testing.repo