Jenkinsfile: ensure all containers are cleaned up
By convention, containers spawned by jenkins jobs have the name:
docker-pr${BUILD_NUMBER}
That works fine for jobs with a single container. This commit cleans up
when multiple containers are spawned with the convention that their names
share the same "docker-pr${BUILD_NUMBER}-" prefix.
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit f470698c2c
)
Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
This commit is contained in:
parent
80727e5a92
commit
4b5c535be9
1 changed files with 2 additions and 0 deletions
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
|
@ -662,6 +662,8 @@ pipeline {
|
|||
sh '''
|
||||
echo "Ensuring container killed."
|
||||
docker rm -vf docker-pr$BUILD_NUMBER || true
|
||||
cids=$(docker ps -aq -f name=docker-pr${BUILD_NUMBER}-*)
|
||||
[ -n "$cids" ] && docker rm -vf $cids || true
|
||||
'''
|
||||
|
||||
sh '''
|
||||
|
|
Loading…
Reference in a new issue