Created
September 28, 2018 12:17
-
-
Save stefanotorresi/907be4ab1fa1dd0674da43f340127d31 to your computer and use it in GitHub Desktop.
Gitlab CI runner cleanup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
export PATH=$PATH:/usr/local/bin:/usr/local/sbin | |
echo "*****" | |
date +%F\ %T | |
echo "stopping gitlab-runner service..." | |
systemctl stop gitlab-runner | |
echo "removing instances..." | |
DOCKER_INSTANCES=$(docker-machine ls -f "{{.Name}}") | |
DROPLETS=$(doctl compute droplet list --tag-name auto-generated --format ID | awk '{if(NR>1)print}') | |
[ -z "${DOCKER_INSTANCES}" ] || docker-machine rm -f ${DOCKER_INSTANCES} | |
[ -z "${DROPLETS}" ] || doctl compute droplet delete -f ${DROPLETS} | |
echo "restarting gitlab-runner service..." | |
systemctl start gitlab-runner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment