[CI] Ensure checkout is cleaned up in packer cache script (#87762)

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tyler Smalley 2021-01-11 10:15:19 -08:00 committed by GitHub
parent f12228e635
commit c2a556bb70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,17 @@ set -e
branch="$1"
checkoutDir="$(pwd)"
function cleanup()
{
if [[ "$branch" != "master" ]]; then
rm --preserve-root -rf "$checkoutDir"
fi
exit 0
}
trap 'cleanup' 0
if [[ "$branch" != "master" ]]; then
checkoutDir="/tmp/kibana-$branch"
git clone https://github.com/elastic/kibana.git --branch "$branch" --depth 1 "$checkoutDir"
@ -56,6 +67,3 @@ echo "created $HOME/.kibana/bootstrap_cache/$branch.tar"
.ci/build_docker.sh
if [[ "$branch" != "master" ]]; then
rm --preserve-root -rf "$checkoutDir"
fi