funcionara???

This commit is contained in:
Alejandro Sarmiento
2024-03-12 17:57:22 +01:00
parent b0cbc6a75b
commit c7efbd6a45

View File

@@ -26,23 +26,26 @@ pipeline {
stage ('Push to Docker Registry') {
steps {
script {
withCredentials()
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 = "https://dockerregistry.alexdev.es/${imageName}"
// Aqu<71> usamos env.REGISTRY_URL para asegurarnos de que estamos usando la variable de entorno correcta
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('https://dockerregistry.alexdev.es', 'dockerregistryalexdev') {
echo "Vamos a ejecutar el docker tag"
sh "docker tag clean-architecture-backend:${version} dockerregistry.alexdev.es/clean-architecture-backend:${version}"
echo "Vamos a ejecutar el docker push"
sh "docker push dockerregistry.alexdev.es/clean-architecture-backend:${version}"
// Iniciar sesi<73>n y subir la imagen
docker.withRegistry(${REGISTRY_URL}, 'dockerregistryalexdev') {
withCredentials([string(credentialsId: 'docker-registry-url-to-push', variable: 'REGISTRY_URL_PUSH')]) {
echo "Vamos a ejecutar el docker tag"
sh "docker tag clean-architecture-backend:${version} ${REGISTRY_URL_PUSH}/clean-architecture-backend:${version}"
echo "Vamos a ejecutar el docker push"
sh "docker push ${REGISTRY_URL_PUSH}/clean-architecture-backend:${version}"
}
}
}
}