borrado de imagenes viejas
This commit is contained in:
@@ -44,6 +44,26 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage ('Clean Old Docker Images') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def currentVersion = env.BUILD_NUMBER.toInteger()
|
||||||
|
def deleteUntilVersion = currentVersion - 3
|
||||||
|
for (int i = 1; i <= deleteUntilVersion; i++) {
|
||||||
|
def tag = "0.0.${i}"
|
||||||
|
|
||||||
|
// Obtener el Docker-Content-Digest
|
||||||
|
def digest = sh(script: "curl -s -H \"Accept: application/vnd.docker.distribution.manifest.v2+json\" -X GET -u ${DOCKER_REGISTRY_USER}:${DOCKER_REGISTRY_PASSWORD} https://${DOCKER_REGISTRY_URL}/v2/clean-architecture-backend/manifests/${tag} | jq -r '.config.digest'", returnStdout: true).trim()
|
||||||
|
|
||||||
|
// Eliminar la imagen usando el Docker-Content-Digest obtenido
|
||||||
|
sh "curl -s -X DELETE -u ${DOCKER_REGISTRY_USER}:${DOCKER_REGISTRY_PASSWORD} https://${DOCKER_REGISTRY_URL}/v2/clean-architecture-backend/manifests/${digest}"
|
||||||
|
|
||||||
|
echo "Eliminada la versi<73>n ${tag} con digest ${digest}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} //stages
|
} //stages
|
||||||
|
|||||||
Reference in New Issue
Block a user