prueba build y push de docker desde jenkinsfile

This commit is contained in:
Alejandro Sarmiento
2024-03-11 18:57:02 +01:00
parent a0c6da36de
commit 04f0b3d376

View File

@@ -25,15 +25,24 @@ pipeline {
} }
} }
stage ('Build') { stage ('Build and Push') {
steps { steps {
script { script {
def version = "0.0.${env.BUILD_NUMBER}" def version = "0.0.${env.BUILD_NUMBER}"
// Inicia sesi<73>n en el Docker Registry
sh "echo ${env.DOCKER_REGISTRY_PASSWORD} | docker login ${env.DOCKER_REGISTRY_URL} -u ${env.DOCKER_REGISTRY_USER} --password-stdin"
echo "docker build -t $DOCKER_REGISTRY_URL/clean-architecture-backend:${version} ." // Construye la imagen Docker con el argumento de build para el entorno y etiqu<71>tala
} sh "docker build --build-arg ENVIRONMENT=${env.ASP_ENVIRONMENT} -t ${env.DOCKER_REGISTRY_URL}/clean-architecture-backend:${version} ."
}
} // Sube la imagen al Docker Registry
sh "docker push ${env.DOCKER_REGISTRY_URL}/clean-architecture-backend:${version}"
// Cierra sesi<73>n en el Docker Registry
sh "docker logout ${env.DOCKER_REGISTRY_URL}"
}
}
}
} //stages } //stages