updated Jenkinsfile

This commit is contained in:
Marvin Zhang
2019-08-08 12:40:58 +08:00
parent 54a29965f6
commit 108b414cd6

19
Jenkinsfile vendored
View File

@@ -52,8 +52,23 @@ pipeline {
steps {
echo 'Cleanup...'
sh """
docker rmi `docker images | grep '<none>' | grep -v IMAGE | awk '{ print \$3 }' | xargs` | true
docker rm `docker ps -a | grep Exited | awk '{ print \$1 }' | xargs` | true
# remove unused containers
container_ids=`docker ps -a | grep Exited | awk '{ print \$1 }' | xargs`
if [ \$container_ids -eq "" ];
then
:
else
docker rm \$container_ids
fi
# remove unused images
image_ids=`docker images | grep '<none>' | grep -v IMAGE | awk '{ print \$3 }' | xargs`
if [ \$image_ids -eq "" ];
then
:
else
docker rmi \$image_ids
fi
"""
}
}