Skip to content

Commit

Permalink
Force remove previous container
Browse files Browse the repository at this point in the history
  • Loading branch information
rmil committed Jul 20, 2021
1 parent a2d11a3 commit 12e453a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ pipeline {
stage('Registry Upload') {
steps {
sh "docker push localhost:5000/ystv/web-auth:$BUILD_ID" // Uploaded to registry
sh "docker image prune -f --filter label=site=auth --filter label=stage=builder" // Removing the local builder image
sh "docker image rm localhost:5000/ystv/web-auth:$BUILD_ID" // Removing the local builder image
}
}
stage('Deploy') {
Expand All @@ -35,7 +33,7 @@ pipeline {
sh 'rsync -av $APP_ENV deploy@web:/data/webs/web-auth/env'
sh '''ssh -tt deploy@web << EOF
docker pull localhost:5000/ystv/web-auth:$BUILD_ID
docker kill ystv-web-auth || true
docker rm -f ystv-web-auth || true
docker run -d -p 1335:8080 --env-file /data/webs/web-api/env --name ystv-web-auth localhost:5000/ystv/web-auth:$BUILD_ID
docker image prune -a -f --filter "label=site=auth"
EOF'''
Expand All @@ -57,7 +55,7 @@ pipeline {
sh "docker pull localhost:5000/ystv/web-auth:$BUILD_ID" // Pulling image from registry
script {
try {
sh "docker kill ystv-web-auth" // Stop old container if it exists
sh "docker rm -f ystv-web-auth" // Stop old container if it exists
}
catch (err) {
echo "Couldn't find container to stop"
Expand All @@ -78,5 +76,9 @@ pipeline {
failure {
echo 'That is not ideal, cheeky bugger'
}
always {
sh "docker image prune -f --filter label=site=auth --filter label=stage=builder" // Removing the local builder image
sh "docker image rm localhost:5000/ystv/web-auth:$BUILD_ID" // Removing the local builder image
}
}
}

0 comments on commit 12e453a

Please sign in to comment.