Add job to cleanup cicd stacks and keypairs
[infra/cicd.git] / jjb / cloud-infra / common / cloud-infra-cleanup-stacks.yaml
diff --git a/jjb/cloud-infra/common/cloud-infra-cleanup-stacks.yaml b/jjb/cloud-infra/common/cloud-infra-cleanup-stacks.yaml
new file mode 100644 (file)
index 0000000..91d5e6e
--- /dev/null
@@ -0,0 +1,73 @@
+---
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2020 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+# A project to remove any CI stacks that are left overnight. The domain
+# reason they would be left is for troubleshooting where the
+# DELETE_STACK option was set to false
+- project:
+    name: 'cloud-infra-cleanup-stacks'
+
+    project: 'cloud-infra-cleanup-stacks'
+
+    cloud:
+      - city:
+          openrc-credentials-file: 'est-jenkins-openrcfile-city-frankfurt-cicd'
+
+    jobs:
+      - 'cloud-infra-cleanup-stack-{cloud}'
+
+- job-template:
+    name: 'cloud-infra-cleanup-stack-{cloud}'
+
+    disabled: '{obj:disabled}'
+
+    concurrent: false
+
+    parameters:
+      - label:
+          name: SLAVE_LABEL
+          default: "engine-package-ubuntu1804-fra"
+          description: "tieing to specific cloud-infra slave so it doesn't end up on another openstack slave randomly"
+      - string:
+          name: STACK_START_STR
+          default: "nordix-cicd-"
+          description: "A pattern of stack names to search for"
+      - string:
+          name: TIMETOLIVE
+          default: "180"
+          description: "Don't delete stacks created in this timeframe of minutes"
+    properties:
+      - logrotate
+
+    triggers:
+      - timed: "@midnight"
+
+    wrappers:
+      - build-timeout:
+          timeout: 180
+      - credentials-binding:
+          - file:
+              credential-id: '{openrc-credentials-file}'
+              variable: OPENRC_FILE
+      - mask-passwords
+      - openstack:
+          single-use: True
+
+    builders:
+      - 'cloud-infra-cleanup-stack-macro'