This commit is contained in:
Alejandro Sarmiento
2024-03-11 21:11:46 +01:00
parent 7e7b8bde30
commit 75a86ea934

View File

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