Skip to content

Instantly share code, notes, and snippets.

@richardsonlima
Created August 15, 2018 14:33
Show Gist options
  • Save richardsonlima/92e0be3c62952d61f4535aedea06b139 to your computer and use it in GitHub Desktop.
Save richardsonlima/92e0be3c62952d61f4535aedea06b139 to your computer and use it in GitHub Desktop.
node("${params.BUILD_AGENT}") {
stage('Dangling Containers') {
sh 'docker ps -q -f status=exited | xargs --no-run-if-empty docker rm'
}
stage('Dangling Images') {
sh 'docker images -q -f dangling=true | xargs --no-run-if-empty docker rmi'
}
stage('Dangling Volumes') {
sh 'docker volume ls -qf dangling=true | xargs -r docker volume rm'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment