Clean the disk cache after every build
This will prevent disk usage explosion
Change-Id: I1d55ee17898e56afd22a52f3efb1aa29f3a5c4be
diff --git a/tools/ci/buildkite.yaml b/tools/ci/buildkite.yaml
index 42f6ebe..3a8008c 100644
--- a/tools/ci/buildkite.yaml
+++ b/tools/ci/buildkite.yaml
@@ -9,13 +9,21 @@
steps:
- label: "x86_64"
- command: tools/bazel ${STARTUP} --output_base=../k8_output_base test ${COMMON} --config=k8 --config=eigen ${TARGETS}
+ commands:
+ - tools/ci/clean-disk.sh
+ - tools/bazel ${STARTUP} --output_base=../k8_output_base test ${COMMON} --config=k8 --config=eigen ${TARGETS}
- label: "roborio"
- command: tools/bazel ${STARTUP} --output_base=../roborio_output_base build ${COMMON} --config=roborio ${ROBORIO_TARGETS}
+ commands:
+ - tools/ci/clean-disk.sh
+ - tools/bazel ${STARTUP} --output_base=../roborio_output_base build ${COMMON} --config=roborio ${ROBORIO_TARGETS}
- label: "armhf-debian"
- command: tools/bazel ${STARTUP} --output_base=../armhf-debian_output_base build ${COMMON} --config=armhf-debian ${TARGETS}
+ commands:
+ - tools/ci/clean-disk.sh
+ - tools/bazel ${STARTUP} --output_base=../armhf-debian_output_base build ${COMMON} --config=armhf-debian ${TARGETS}
- label: "cortex-m4f"
- command: tools/bazel ${STARTUP} --output_base=../cortex-m4f_output_base build ${COMMON} --config=cortex-m4f ${M4F_TARGETS}
+ commands:
+ - tools/ci/clean-disk.sh
+ - tools/bazel ${STARTUP} --output_base=../cortex-m4f_output_base build ${COMMON} --config=cortex-m4f ${M4F_TARGETS}
diff --git a/tools/ci/clean-disk.sh b/tools/ci/clean-disk.sh
index e86d5a3..213a134 100755
--- a/tools/ci/clean-disk.sh
+++ b/tools/ci/clean-disk.sh
@@ -1,15 +1,15 @@
#!/bin/bash
-#Retrieve Jenkins node name or set a test value
-NODE_NAME=${NODE_NAME:-"TEST971"}
-#Set default for disk utilisation
-DMAX=${1:-80%}
-#Retrieve disk usages in percentage
-DSIZE=$(df -hlP /home/jenkins | sed 1d | awk '{print $5}')
+# Set default for disk utilisation
+readonly DMAX="${1:-80%}"
+# Cache folder
+readonly CACHE_FOLDER="${HOME}/.cache/bazel/disk_cache/"
+# Retrieve disk usages in percentage
+readonly DSIZE="$(df -hlP "${CACHE_FOLDER}" | sed 1d | awk '{print $5}')"
-if [[ $DSIZE>$DMAX ]]; then
- echo $NODE_NAME": Disk over "$DMAX" Clean up needed on node."
- rm -rf ~jenkins/.cache/bazel/disk_cache;
+if [[ ${DSIZE} > ${DMAX} ]]; then
+ echo "$(hostname): Disk over ${DMAX} Clean up needed on node."
+ rm -rf "${CACHE_FOLDER}"
else
- echo $NODE_NAME": No clean up needed. Disk usage is at: "$DSIZE
+ echo "$(hostname): No clean up needed. Disk usage is at: ${DSIZE}"
fi