format ci/jenkins/jenkinsfile/publishImages.groovy

Former-commit-id: 1d950f1eb8fcbf642cdb99ca944fb788cf4a1b23
pull/191/head
milvus-ci-robot 2019-10-19 15:51:34 +08:00
parent 9025f44cbe
commit 6ff0afad2c
1 changed files with 12 additions and 6 deletions

View File

@ -15,21 +15,27 @@ container('publish-images') {
def imageName = "${PROJECT_NAME}/engine:${DOCKER_VERSION}"
try {
def isExistImage = sh(returnStatus: true, script: "docker inspect --type=image ${imageName} 2>&1 > /dev/null")
if (isExistImage == 0) {
sh "docker rmi ${imageName}"
def isExistSourceImage = sh(returnStatus: true, script: "docker inspect --type=image ${imageName} 2>&1 > /dev/null")
if (isExistSourceImage == 0) {
def removeSourceImageStatus = sh(returnStatus: true, script: "docker rmi ${imageName}")
}
def customImage = docker.build("${imageName}")
def isExistTargeImage = sh(returnStatus: true, script: "docker inspect --type=image ${dockerRegistryURL}/${imageName} 2>&1 > /dev/null")
if (isExistTargeImage == 0) {
def removeTargeImageStatus = sh(returnStatus: true, script: "docker rmi ${dockerRegistryURL}/${imageName}")
}
docker.withRegistry("https://${dockerRegistryURL}", "${params.DOCKER_CREDENTIALS_ID}") {
customImage.push()
}
} catch (exc) {
throw exc
} finally {
def isExistImage = sh(returnStatus: true, script: "docker inspect --type=image ${imageName} 2>&1 > /dev/null")
if (isExistImage == 0) {
sh "docker rmi ${imageName}"
def isExistSourceImage = sh(returnStatus: true, script: "docker inspect --type=image ${imageName} 2>&1 > /dev/null")
if (isExistSourceImage == 0) {
def removeSourceImageStatus = sh(returnStatus: true, script: "docker rmi ${imageName}")
}
}
}