From 82813fd0937eb796d01d02dc651e01817ad2b30f Mon Sep 17 00:00:00 2001 From: Vladimir Khlyunev Date: Mon, 18 Mar 2019 11:43:57 +0400 Subject: [PATCH] Add image promotion job Change-Id: I994859c8317ba2d85c575f0b1ae5d55275a5b5a4 --- .../common/jobs/promote_staging_image.yaml | 35 +++++++++++++++++++ .../common/scripts/promote_staging_image.sh | 26 ++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 maintenance-ci/common/jobs/promote_staging_image.yaml create mode 100755 maintenance-ci/common/scripts/promote_staging_image.sh diff --git a/maintenance-ci/common/jobs/promote_staging_image.yaml b/maintenance-ci/common/jobs/promote_staging_image.yaml new file mode 100644 index 0000000..7a5a028 --- /dev/null +++ b/maintenance-ci/common/jobs/promote_staging_image.yaml @@ -0,0 +1,35 @@ +- job: + name: 'promote-staging-image' + description: "Delete actual image and cut '-staging' from image name" + + concurrent: false + node: 'jenkins-master' + + parameters: + - string: + name: IMAGE_NAME + description: "Name of image WITHOUT 'staging' - used for glance" + default: "" + + scm: + - git: + url: 'https://review.fuel-infra.org/tools/sustaining/' + branches: + - origin/master + + wrappers: + - timestamps + - openstack-creds + - credentials-binding: + - username-password-separated: + credential-id: maintenance-ci-robot-password + username: JJB_USER + password: JJB_PASS + + - timeout: + fail: true + timeout: 30 + + builders: + - shell: + !include-raw: common/scripts/promote_staging_image.sh diff --git a/maintenance-ci/common/scripts/promote_staging_image.sh b/maintenance-ci/common/scripts/promote_staging_image.sh new file mode 100755 index 0000000..c95495c --- /dev/null +++ b/maintenance-ci/common/scripts/promote_staging_image.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -ex + +pushd maintenance-ci + +STAGING_IMAGE_NAME="${IMAGE_NAME?}-staging" +GLANCE_IMAGE_NAME="${IMAGE_NAME?}" + +set +x +source "${OPENRC_FILE?}" +OPENSTACK_CLIENTS_VENV="${OPENSTACK_CLIENTS_VENV:-/home/jenkins/venv-openstack-clients}" +if [[ ! -d "${OPENSTACK_CLIENTS_VENV}" ]] ; then + pip install virtualenv + virtualenv "${OPENSTACK_CLIENTS_VENV}" + source "${OPENSTACK_CLIENTS_VENV}"/bin/activate + pip install openstackclient + deactivate +fi +source "${OPENSTACK_CLIENTS_VENV}"/bin/activate + +set -x +openstack image show "${STAGING_IMAGE_NAME}" +openstack image delete "${GLANCE_IMAGE_NAME}" || true +openstack image set --name "${GLANCE_IMAGE_NAME}" "${STAGING_IMAGE_NAME}" +deactivate \ No newline at end of file -- 2.45.2