]> review.fuel-infra Code Review - tools/sustaining.git/commitdiff
Add image promotion job 83/40783/1
authorVladimir Khlyunev <vkhlyunev@mirantis.com>
Mon, 18 Mar 2019 07:43:57 +0000 (11:43 +0400)
committerVladimir Khlyunev <vkhlyunev@mirantis.com>
Mon, 18 Mar 2019 07:43:57 +0000 (11:43 +0400)
Change-Id: I994859c8317ba2d85c575f0b1ae5d55275a5b5a4

maintenance-ci/common/jobs/promote_staging_image.yaml [new file with mode: 0644]
maintenance-ci/common/scripts/promote_staging_image.sh [new file with mode: 0755]

diff --git a/maintenance-ci/common/jobs/promote_staging_image.yaml b/maintenance-ci/common/jobs/promote_staging_image.yaml
new file mode 100644 (file)
index 0000000..7a5a028
--- /dev/null
@@ -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 (executable)
index 0000000..c95495c
--- /dev/null
@@ -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