diff --git a/Jenkinsfile b/Jenkinsfile index a92d7aa..0350818 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { steps { withDockerRegistry([ credentialsId: "6ff44976-23cd-4cc2-902c-de8c340e65e5", url: "https://reg.zknt.org" ]) { script { - def customImage = docker.build("reg.zknt.org/zknt/debian", "--build-arg DATE=$timeStamp --build-arg GOSU_VERSION=$gosu_version --build-arg DUMB_INIT_VERSION=$dumb_init_version --no-cache --pull .") + def customImage = docker.build("reg.zknt.org/zknt/debian", "--pull --build-arg DATE=$timeStamp --build-arg GOSU_VERSION=$gosu_version --build-arg DUMB_INIT_VERSION=$dumb_init_version --no-cache .") customImage.push("buster") customImage.push("stable") customImage.push("10") @@ -26,6 +26,10 @@ pipeline { } } post { + success { + 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""" + } always { emailext body: 'build finished', subject: '[jenkins] docker debian: ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true }