From 80e399ba20a2a1cc4b6c0595389e497f14ecfde0 Mon Sep 17 00:00:00 2001 From: Kent Knox Date: Thu, 28 Sep 2017 12:02:01 -0500 Subject: [PATCH] Making docker_clean_images more resilient To the failure of deleting images. [ROCm/clr commit: c6af44f67d901a95f5f1b0699bcd232258db7613] --- projects/clr/hipamd/Jenkinsfile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/Jenkinsfile b/projects/clr/hipamd/Jenkinsfile index 01e1e1d1da..3d8415078d 100644 --- a/projects/clr/hipamd/Jenkinsfile +++ b/projects/clr/hipamd/Jenkinsfile @@ -62,8 +62,20 @@ def docker_clean_images( String org, String image_name ) // The script returns a 0 for success (images were found ) if( docker_images == 0 ) { - // run bash script to clean images:tags after successful pushing - sh "docker images | grep \"${org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" + // Deleting images can fail, if other projects have built on top of that image and are now dependent on it. + // This should not be treated as a hip build failure. This requires cleanup at a later time, possibly through + // another job + try + { + // Best attempt to run bash script to clean images + // deleting images based on hash seems to be more stable than through name:tag values because of tags + sh "docker images | grep \"${org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" + } + catch( err ) + { + println 'Failed to cleanup a few images; probably the images are used as a base for other images' + currentBuild.result = 'SUCCESS' + } } }