jjb: xci: Add postbuild publisher script to remove clean VM
[releng.git] / jjb / xci / xci-cleanup.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018 SUSE and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 #----------------------------------------------------------------------
12 # This script is used by CI and executed by Jenkins jobs.
13 # You are not supposed to use this script manually if you don't know
14 # what you are doing.
15 #----------------------------------------------------------------------
16
17 # Need to cover macros with and without parameters
18 VM_NAME=$DISTRO
19 VM_NAME+=_xci_vm
20
21 # skip the deployment if the patch doesn't impact the deployment
22 if [[ "$GERRIT_TOPIC" =~ 'skip-verify' ]]; then
23     echo "Skipping the deployment!"
24     exit 0
25 fi
26
27 sudo virsh destroy $VM_NAME || true
28 sudo virsh undefine $VM_NAME || true