diff --git a/Jenkinsfile b/Jenkinsfile index 564b80d..9b2e84a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,20 +21,21 @@ pipeline { def io_registry_image = repo + '/' + project + ':' + version sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image sh "docker push " + io_registry_image - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + "buster" - sh "docker push " + io_registry_image.split(/\:/)[0] + "buster" - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + "stable" - sh "docker push " + io_registry_image.split(/\:/)[0] + "stable" + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + ":buster" + sh "docker push " + io_registry_image.split(/\:/)[0] + ":buster" + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + ":stable" + sh "docker push " + io_registry_image.split(/\:/)[0] + ":stable" } def quay_credentials= "18fb6f7e-c6bc-4d06-9bf9-08c2af6bfc1a" withDockerRegistry([ credentialsId: quay_credentials, url: "https://quay.io" ]) { def quay_image = 'quay.io/' + repo + '/' + project + ':' + version + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + quay_image sh "docker push " + quay_image - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0] + "buster" - sh "docker push " + official_image.split(/\:/)[0] + "buster" - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0] + "stable" - sh "docker push " + official_image.split(/\:/)[0] + "stable" + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + quay_image.split(/\:/)[0] + ":buster" + sh "docker push " + quay_image.split(/\:/)[0] + ":buster" + sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + quay_image.split(/\:/)[0] + ":stable" + sh "docker push " + quay_image.split(/\:/)[0] + ":stable" } } } @@ -44,8 +45,9 @@ pipeline { post { success { + sh """docker image prune -f""" sh """docker rmi -f \$(docker images -q $registry/$repo/$project:$version)""" - sh """for image in \$(grep FROM Dockerfile | cut -d ' ' -f 2); do docker rmi -f \$(docker images -q \${image}); done""" + sh """for image in \$(grep FROM Dockerfile | cut -d ' ' -f 2 | grep -vi SCRATCH); do docker rmi -f \$(docker images -q \${image}); done""" } always { emailext body: 'build finished', subject: '[jenkins] docker '+project+'('+version+'): ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true