52 lines
1.7 KiB
Plaintext
52 lines
1.7 KiB
Plaintext
pipeline {
|
|
agent any
|
|
|
|
environment {
|
|
ASP_ENVIRONMENT = 'Production'
|
|
}
|
|
|
|
stages {
|
|
stage ('Unit Tests') {
|
|
steps {
|
|
script {
|
|
sh 'dotnet test ./CleanArchitecture/CleanArchitecture.Application.UnitTests'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage ('Checkout') {
|
|
steps {
|
|
checkout scm
|
|
}
|
|
}
|
|
|
|
|
|
stage ('Push to Docker Registry') {
|
|
steps {
|
|
script {
|
|
def version = "0.0.${env.BUILD_NUMBER}"
|
|
def imageName = "clean-architecture-backend:${version}"
|
|
|
|
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ón y subir la imagen
|
|
sh "echo ${REGISTRY_PASSWORD} | docker login ${REGISTRY_URL} -u ${REGISTRY_USER} --password-stdin"
|
|
sh "docker tag ${imageName} ${fullImageName}"
|
|
sh "docker push ${fullImageName}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} //stages
|
|
}
|