This commit is contained in:
Alejandro Sarmiento
2024-03-12 18:03:22 +01:00
parent c7efbd6a45
commit eaddbbae69

View File

@@ -32,19 +32,20 @@ pipeline {
// Usando withCredentials para manejar el REGISTRY_URL // Usando withCredentials para manejar el REGISTRY_URL
withCredentials([string(credentialsId: 'docker-registry-url', variable: 'REGISTRY_URL')]) { withCredentials([string(credentialsId: 'docker-registry-url', variable: 'REGISTRY_URL')]) {
// Aqu<71> usamos env.REGISTRY_URL para asegurarnos de que estamos usando la variable de entorno correcta
def fullImageName = "${REGISTRY_URL}/${imageName}" def fullImageName = "${REGISTRY_URL}/${imageName}"
// Construir la imagen
sh "docker build --build-arg ENVIRONMENT=${env.ASP_ENVIRONMENT} -t ${imageName} ./CleanArchitecture/" sh "docker build --build-arg ENVIRONMENT=${env.ASP_ENVIRONMENT} -t ${imageName} ./CleanArchitecture/"
// Iniciar sesi<73>n y subir la imagen
docker.withRegistry(${REGISTRY_URL}, 'dockerregistryalexdev') { docker.withRegistry(${REGISTRY_URL}, 'dockerregistryalexdev') {
withCredentials([string(credentialsId: 'docker-registry-url-to-push', variable: 'REGISTRY_URL_PUSH')]) { withCredentials([string(credentialsId: 'docker-registry-url-to-push', variable: 'REGISTRY_URL_PUSH')]) {
echo "Vamos a ejecutar el docker tag" echo "Vamos a ejecutar el docker tag"
sh "docker tag clean-architecture-backend:${version} ${REGISTRY_URL_PUSH}/clean-architecture-backend:${version}" sh "docker tag ${imageName} ${REGISTRY_URL_PUSH}/${imageName}"
echo "Vamos a ejecutar el docker push" echo "Vamos a ejecutar el docker push"
sh "docker push ${REGISTRY_URL_PUSH}/clean-architecture-backend:${version}" sh "docker push ${REGISTRY_URL_PUSH}/${imageName}"
} }
} }
} }