Make zuul jobs reusable for internal zuul setup

This change makes zuul jobs configurable on project level using variables.
That allows to reuse same jobs in other zuul setup with different base images,
docker registry and proxy settings.

Change-Id: I301ea09f42bc1498d3cba45eede075e0d5a6f8fa
This commit is contained in:
Svetlana Shturm 2020-06-24 16:51:45 -05:00
parent aa3fca532a
commit c40ffbdd8b
2 changed files with 37 additions and 4 deletions

View File

@ -20,6 +20,16 @@
vars:
rtd_webhook_id: '38574'
rtd_project_name: 'airship-pegleg'
proxy: ""
no_proxy: ""
use_proxy: false
docker_registry: "quay.io"
docker_registry_login_url: "https://quay.io/api/v1/"
deb_docker_repo: "{{ zuul_site_mirror_fqdn }}/deb-docker"
image_prefix: "airshipit"
base_image_bionic: "ubuntu:18.04"
base_image_opensuse: "opensuse/leap:15.1"
base_image_xenial: "ubuntu:16.04"
check:
jobs:
- openstack-tox-pep8

View File

@ -29,6 +29,21 @@
- debug:
msg: "{{ tags | to_json }}"
- name: Set ubuntu bionic base image
set_fact:
base_image: "{{ base_image_bionic }}"
when: distro == 'ubuntu_bionic'
- name: Set ubuntu xenial base image
set_fact:
base_image: "{{ base_image_xenial }}"
when: distro == 'ubuntu_xenial'
- name: Set ubuntu opensuse base image
set_fact:
base_image: "{{ base_image_opensuse }}"
when: distro == 'opensuse_15'
- name: Determine tags
shell: echo '{{ tags | to_json }}' | python {{ zuul.project.src_dir }}/tools/image_tags.py
environment:
@ -67,7 +82,7 @@
- apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
- apt_repository:
repo: deb http://{{ zuul_site_mirror_fqdn }}/deb-docker xenial stable
repo: "deb http://{{ deb_docker_repo }} xenial stable"
- apt:
name: "{{ item }}"
allow_unauthenticated: True
@ -95,8 +110,12 @@
chdir: "{{ zuul.project.src_dir }}"
target: images
params:
BASE_IMAGE: "{{ base_image }}"
DISTRO: "{{ distro }}"
IMAGE_TAG: "{{ item }}"
PROXY: "{{ proxy }}"
NO_PROXY: "{{ no_proxy }}"
USE_PROXY: "{{ use_proxy | lower }}"
with_items: "{{ image_tags.stdout_lines }}"
- shell: "docker images"
@ -112,18 +131,22 @@
- docker_login:
username: "{{ airship_pegleg_quay_creds.username }}"
password: "{{ airship_pegleg_quay_creds.password }}"
registry_url: "https://quay.io/api/v1/"
registry_url: "{{ docker_registry_login_url }}"
- make:
chdir: "{{ zuul.project.src_dir }}"
target: images
params:
DOCKER_REGISTRY: "quay.io"
IMAGE_PREFIX: "airshipit"
BASE_IMAGE: "{{ base_image }}"
DOCKER_REGISTRY: "{{ docker_registry }}"
IMAGE_PREFIX: "{{ image_prefix }}"
DISTRO: "{{ distro }}"
IMAGE_TAG: "{{ item }}"
COMMIT: "{{ zuul.newrev | default('') }}"
PUSH_IMAGE: "true"
PROXY: "{{ proxy }}"
NO_PROXY: "{{ no_proxy }}"
USE_PROXY: "{{ use_proxy | lower }}"
with_items: "{{ image_tags.stdout_lines }}"
- shell: "docker images"