Skip to content

Commit

Permalink
fix cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pcaskey committed Nov 11, 2022
1 parent c1b0686 commit 965ca28
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ pipeline {
script {
try{
echo "Cleaning up artifacts from the build..."
sh "result=${5}(docker ps -a | grep ${imagename}_${tag});if [ ! -z \"${5}result\" ]; then docker rm -f ${5}(docker ps -a | grep ${imagename}_${tag} | awk '{print ${5}1}');fi;docker rmi -f ${imagename}_${tag}"
sh "result=${5}(docker ps -a | grep ${imagename}_${tag}:arm64);if [ ! -z \"${5}result\" ]; then docker rm -f ${5}(docker ps -a | grep ${imagename}_${tag}:arm64 | awk '{print ${5}1}');fi;docker rmi -f ${imagename}_${tag}:arm64"
sh 'tests/cleanup.sh'
} catch(error) {
def error_details = readFile('./debug');
def message = "BUILD ERROR: There was a problem with cleanup of the image. \n\n ${error_details}"
Expand Down
19 changes: 19 additions & 0 deletions tests/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

. ./common.bash

result=$(docker ps -a | grep ${imagename}_${tag})
if [ ! -z "$result" ]; then
echo "removing existing containers"
docker rm -f $(docker ps -a | grep ${imagename}_${tag} | awk '{print $1}')
fi
docker rmi -f ${imagename}_${tag}

result2=$(docker ps -a | grep ${imagename}_${tag}:arm64)
if [ ! -z "$result2" ]; then
echo "removing existing containers"
docker rm -f $(docker ps -a | grep ${imagename}_${tag}:arm64 | awk '{print $1}')
fi
docker rmi -f ${imagename}_${tag}:arm64


0 comments on commit 965ca28

Please sign in to comment.