diff --git a/test/ci-cleanup.sh b/test/ci-cleanup.sh index 224a5f00..7eb15589 100755 --- a/test/ci-cleanup.sh +++ b/test/ci-cleanup.sh @@ -4,11 +4,15 @@ set -e echo "Cleanup artifacts of previous runs" # containerlab will figure out previous run locations from the docker containers -previous_topos=$(docker inspect -f '{{ index .Config.Labels "clab-topo-file" }}' $(docker ps -aq)) -for topo in previous_topos; do - previous_lab_dir=$(dirname $topo) - mkdir -p "${previous_lab_dir}/clab-mini-lab" -done +running_containers=$(docker ps -aq) + +if [ ! -z "$running_containers" ]; then + previous_topos=$(docker inspect -f '{{ index .Config.Labels "clab-topo-file" }}' $(docker ps -aq)) + for topo in previous_topos; do + previous_lab_dir=$(dirname $topo) + mkdir -p "${previous_lab_dir}/clab-mini-lab" + done +fi make cleanup