Build and push images into registry

It's a first approach - we build & push images after merge tagging them
with BUILD_NUMBER and we can aslo build & push images from a separate
job tagging them with latest.

Change-Id: Ifda8db0b23cc388e596aa90c84c528a587ce6748
This commit is contained in:
Artur Zarzycki 2016-08-03 11:19:50 +02:00 committed by Marek Zawadzki
parent e3d193b6ae
commit 99984b9635
3 changed files with 95 additions and 14 deletions

49
jenkins-tp/jobs/builders/mcp-build-images.sh Normal file → Executable file
View File

@ -1,22 +1,51 @@
#!/bin/bash -ex
ls -al
# Builds MCP images and pushes them to Docker registry with configurable
# tag.
# Optionally it can purge n older images (works correctly if tag is
# numerical).
# This script assumes that user is already authenticated to Docker
# registry (e.g. by running 'docker login').
# Parameters must be passed via env variables.
# CONFIGURATION:
######################################################
DOCKER_REGISTRY="registry.mcp.fuel-infra.org"
DOCKER_NAMESPACE="mcp"
IMAGES_MAINTAINER="mos-microservices@mirantis.com"
REPOSITORIES_PATH="microservices-repos"
: ${TAG:="latest"}
: ${PURGE:="false"}
: ${PURGE_COUNT:="5"}
# Install fuel-ccp:
virtualenv mcp
source mcp/bin/activate
pip install .
# Build images:
ccp \
--images-maintainer mos-microservices@mirantis.com \
--builder-no-cache \
--builder-push \
--auth-registry \
--builder-registry registry01-bud.ng.mirantis.net \
--auth-registry-username $REG_USER \
--auth-registry-password $REG_PASS \
--images-namespace nextgen \
--images-tag latest \
--repositories-path microservices-repos \
--registry-address ${DOCKER_REGISTRY} \
--images-namespace ${DOCKER_NAMESPACE} \
--images-tag ${TAG} \
--images-maintainer ${IMAGES_MAINTAINER} \
--repositories-path ${REPOSITORIES_PATH} \
build
deactivate
# Purge images if requested:
if [ ${PURGE} == "true" ] && [[ ${TAG} =~ ^[0-9]+$ ]];
then
TAG_TO_DELETE=`expr $TAG - $PURGE_COUNT`
#FIXME (mzawadzki): remove 'echo' after tests to really rmi images
#FIXME (mzawadzki): this will remove images locally but not from
#remote registry
docker images| tail -n +2| awk -v TAG_TO_DELETE=${TAG_TO_DELETE} \
'$2 == TAG_TO_DELETE {system("echo docker rmi " $1 ":"TAG_TO_DELETE);}'\
&& true
fi

View File

@ -1,11 +1,15 @@
- job-template:
name: mcp-build-images
name: mcp-build-images-latest
description: |
Build MCP Docker images and store them into Docker registry.
Build MCP Docker images and store them into Docker registry with latest tag.
node: standard
builders:
- inject:
properties-content: |
TAG=latest
PURGE=false
- shell:
!include-raw 'builders/mcp-build-images.sh'
!include-raw-escape 'builders/mcp-build-images.sh'
concurrent: false
scm:
- openstack:
@ -15,7 +19,31 @@
wrappers:
- ng-cleanup
- job-template:
name: mcp-build-images-build-number
description: |
Build MCP Docker images and store them into Docker registry with BUILD_NUMBER as a tag.
node: standard
builders:
- inject:
properties-content: |
TAG=$BUILD_NUMBER
PURGE=true
PURGE_COUNT=5
- shell:
!include-raw-escape 'builders/mcp-build-images.sh'
concurrent: true
scm:
- openstack:
scm-basedir: ''
scm-branch: 'master'
scm-repo: 'openstack/fuel-ccp'
wrappers:
- ng-cleanup
- project:
name: Build MCP Docker images and store them into Docker registry.
jobs:
- 'mcp-build-images'
- 'mcp-build-images-latest'
- 'mcp-build-images-build-number'

View File

@ -52,10 +52,14 @@ projects:
- name: openstack/fuel-ccp
check:
- fuel-ccp-gate-job
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-debian-base
check:
- test-build-base
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-ext-config
check:
@ -64,42 +68,62 @@ projects:
- name: openstack/fuel-ccp-etcd
check:
- test-build-etcd
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-glance
check:
- test-build-glance
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-horizon
check:
- test-build-horizon
post:
- mcp-build-images-build-id
- name: openstack/fuel-ccp-keystone
check:
- test-build-keystone
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-mariadb
check:
- test-build-mariadb
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-memcached
check:
- test-build-memcached
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-neutron
check:
- test-build-neutron
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-nova
check:
- test-build-nova
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-openstack-base
check:
- test-build-openstackbase
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-rabbitmq
check:
- test-build-rabbitmq
post:
- mcp-build-images-build-number
- name: openstack/fuel-ccp-installer
check: