Generalize the cleanup script for reuse in global-jjb.
Issue: RELENG-1436
Change-Id: I88e1bc3136b2f9b2542e441a74f26d742679c353
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
--- /dev/null
+---
+- project:
+ name: openstack-cron-full-test
+ jobs:
+ - 'gerrit-openstack-cron'
+
+ project-name: ciman-full
+ openstack-cloud: example-cloud
+ openstack-image-cleanup: false
+ openstack-image-cleanup-age: 42
--- /dev/null
+---
+- project:
+ name: openstack-cron-minimal-test
+ jobs:
+ - 'gerrit-openstack-cron'
+
+ project-name: ci-management
:git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
:openstack-cloud: OS_CLOUD setting to pass to openstack client.
(default: vex)
+ :openstack-image-cleanup: Whether or not to run the image cleanup script.
+ (default: true)
+ :openstack-image-cleanup-age: Age in days of image before marking it for
+ removal. (default: 30)
:stream: Keyword that can be used to represent a release code-name.
Often the same as the branch. (default: master)
:submodule-recursive: Whether to checkout submodules recursively.
:submodule-timeout: Timeout (in minutes) for checkout operation.
(default: 10)
+Minimal Example:
+
+.. literalinclude:: ../../.jjb-test/lf-ci-jobs/openstack-cron-minimal.yaml
+
+Full Example:
+
+.. literalinclude:: ../../.jjb-test/lf-ci-jobs/openstack-cron-full.yaml
+
+
.. _gjjb-packer-merge:
Packer Merge
git-url: '$GIT_URL/$PROJECT'
github-url: 'https://github.com'
openstack-cloud: vex
+ openstack-image-cleanup: true
+ openstack-image-cleanup-age: 30
stream: master
submodule-timeout: 10
- lf-infra-pre-build
- inject:
properties-content: OS_CLOUD={openstack-cloud}
+ # Images
- shell: !include-raw-escape: ../shell/openstack-protect-in-use-images.sh
+ - conditional-step:
+ condition-kind: boolean-expression
+ condition-expression: '{openstack-image-cleanup}'
+ steps:
+ - inject:
+ properties-content: OS_IMAGE_CLEANUP_AGE={openstack-image-cleanup-age}
+ - shell: !include-raw-escape: ../shell/openstack-cleanup-old-images.sh
publishers:
- lf-infra-publish
--- /dev/null
+---
+features:
+ - |
+ The **openstack-cron** job now has the ability to remove images older than
+ a specified age (default: 30).
--- /dev/null
+#!/bin/bash -l
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2017, 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+# Removes openstack images older than X days in the cloud
+echo "---> Cleanup old images"
+
+os_cloud="${OS_CLOUD:-vex}"
+os_image_cleanup_age="${OS_IMAGE_CLEANUP_AGE:-30}"
+
+set -eux -o pipefail
+
+lftools openstack --os-cloud "${os_cloud}" image cleanup --days="${os_image_cleanup_age}"