Skip to content

Commit 6b42095

Browse files
committed
bk: add post-checkout hook to cleanup containers
Signed-off-by: Ivo Jimenez <ivo.jimenez@gmail.com>
1 parent 90bb567 commit 6b42095

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

.buildkite/hooks/post-checkout

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# important: assumes that each agent runs a single job at a time
2+
3+
# ignore errors
4+
set +e
5+
6+
if [[ $BUILDKITE_AGENT_META_DATA_QUEUE == "pipeline-uploader" ]]; then
7+
echo "Skipping on `pipeline-uploader` agents"
8+
exit 0
9+
fi
10+
11+
echo "Cleaning up unused docker containers"
12+
for id in $(docker ps --quiet); do
13+
echo "Killing $id"
14+
docker kill $id
15+
done
16+
17+
docker system prune --all --volumes --force

0 commit comments

Comments
 (0)