env.REGISTRY_URL

This commit is contained in:
Alejandro Sarmiento
2024-03-11 21:16:47 +01:00
parent 75a86ea934
commit 073b3bc2f8

View File

@@ -26,20 +26,22 @@ pipeline {
script { script {
def version = "0.0.${env.BUILD_NUMBER}" def version = "0.0.${env.BUILD_NUMBER}"
def imageName = "clean-architecture-backend:${version}" def imageName = "clean-architecture-backend:${version}"
withCredentials([ // Usando withCredentials para manejar el REGISTRY_URL
string(credentialsId: 'docker-registry-url', variable: 'REGISTRY_URL'), withCredentials([string(credentialsId: 'docker-registry-url', variable: 'REGISTRY_URL')]) {
usernamePassword(credentialsId: 'dockerregistryalexdev', usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_PASSWORD') // Aqu<71> usamos env.REGISTRY_URL para asegurarnos de que estamos usando la variable de entorno correcta
]) { def fullImageName = "env.REGISTRY_URL/${imageName}"
def fullImageName = "${REGISTRY_URL}/${imageName}"
// Construir la imagen // 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 // Iniciar sesi<73>n y subir la imagen
sh "echo ${REGISTRY_PASSWORD} | docker login ${REGISTRY_URL} -u ${REGISTRY_USER} --password-stdin" docker.withRegistry(env.REGISTRY_URL, 'dockerregistryalexdev') {
sh "docker tag ${imageName} ${fullImageName}" echo "Vamos a ejecutar el docker tag"
sh "docker push ${fullImageName}" sh "docker tag ${imageName} ${fullImageName}"
echo "Vamos a ejecutar el docker push"
sh "docker push ${fullImageName}"
}
} }
} }
} }