Fixed service-nest.yml

This commit is contained in:
Duvan Rondon 2025-02-24 15:28:39 -05:00
parent 6a13eb31e0
commit 5a2ee2b43e
2 changed files with 36 additions and 32 deletions

View File

@ -19,25 +19,18 @@ pipeline {
stage('Authenticate') { stage('Authenticate') {
steps { steps {
sh ''' sh 'gcloud auth activate-service-account --key-file="$GCLOUD_CREDS"'
gcloud auth activate-service-account --key-file="$GCLOUD_CREDS"
'''
} }
} }
stage('Deploy to Cloud Run Firmador') { stage('Deploy to Cloud Run Firmador') {
steps { steps {
script { script {
// Ejecuta el comando capturando stdout + stderr
def output = sh(script: "gcloud run services replace service-firmador.yml --platform=managed --region=${REGION} 2>&1", returnStdout: true).trim() def output = sh(script: "gcloud run services replace service-firmador.yml --platform=managed --region=${REGION} 2>&1", returnStdout: true).trim()
// Busca la URL en la salida usando expresión regular
def cloudRunUrlMatch = output =~ /URL:\s+(https:\/\/[^\s]+)/ def cloudRunUrlMatch = output =~ /URL:\s+(https:\/\/[^\s]+)/
if (cloudRunUrlMatch) { if (cloudRunUrlMatch) {
def cloudRunUrl = cloudRunUrlMatch[0][1] // Captura la URL env.CLOUD_RUN_FIRMADOR = cloudRunUrlMatch[0][1]
env.CLOUD_RUN_FIRMADOR = cloudRunUrl }
}
} }
} }
} }
@ -45,8 +38,8 @@ pipeline {
stage('Envs about Firmador') { stage('Envs about Firmador') {
steps { steps {
sh ''' sh '''
sed -i "s|SERVICE_FIRMADOR_URL|${CLOUD_RUN_FIRMADOR}|g" **.yml sed -i "s|SERVICE_FIRMADOR_URL|${CLOUD_RUN_FIRMADOR}|g" **.yml
cat service-nest.yml cat service-nest.yml
''' '''
} }
} }
@ -54,25 +47,36 @@ pipeline {
stage('Deploy to Cloud Run Nest and Spring') { stage('Deploy to Cloud Run Nest and Spring') {
steps { steps {
script { script {
// Ejecuta el comando capturando stdout + stderr def outputNest = sh(script: "gcloud run services replace service-nest.yml --platform=managed --region=${REGION} 2>&1", returnStdout: true).trim()
def output = sh(script: "gcloud run services replace service-firmador.yml --platform=managed --region=${REGION} 2>&1", returnStdout: true).trim() def outputSpring = sh(script: "gcloud run services replace service-spring.yml --platform=managed --region=${REGION} 2>&1", returnStdout: true).trim()
// Busca la URL en la salida usando expresión regular def cloudRunUrlMatchNest = outputNest =~ /URL:\s+(https:\/\/[^\s]+)/
def cloudRunUrlMatch = output =~ /URL:\s+(https:\/\/[^\s]+)/ def cloudRunUrlMatchSpring = outputSpring =~ /URL:\s+(https:\/\/[^\s]+)/
if (cloudRunUrlMatch) { if (cloudRunUrlMatchNest) {
def cloudRunUrl = cloudRunUrlMatch[0][1] // Captura la URL env.CLOUD_RUN_NEST = cloudRunUrlMatchNest[0][1]
env.CLOUD_RUN_FIRMADOR = cloudRunUrl }
} if (cloudRunUrlMatchSpring) {
env.CLOUD_RUN_SPRING = cloudRunUrlMatchSpring[0][1]
}
} }
} }
} }
stage('Envs about Firmador') { stage('Envs about Nest and Spring') {
steps { steps {
sh ''' sh '''
sed -i "s|SERVICE_FIRMADOR_URL|${CLOUD_RUN_FIRMADOR}|g" **.yml sed -i "s|SERVICE_NEST_URL|${CLOUD_RUN_NEST}|g" **.yml
cat service-nest.yml sed -i "s|SERVICE_SPRING_URL|${CLOUD_RUN_SPRING}|g" **.yml
cat service-api-gateway.yml
'''
}
}
stage('Deploy Api Gateway') {
steps {
sh '''
gcloud run services replace service-api-gateway.yml --platform='managed' --region='us-central1'
''' '''
} }
} }
@ -80,7 +84,7 @@ pipeline {
stage('Allow allUsers') { stage('Allow allUsers') {
steps { steps {
sh ''' sh '''
gcloud run services add-iam-policy-binding cbii-apigateway-jenkins --region='us-central1' --member='allUsers' --role='roles/run.invoker' gcloud run services add-iam-policy-binding cbii-apigateway-jenkins --region='us-central1' --member='allUsers' --role='roles/run.invoker'
''' '''
} }
} }

View File

@ -103,10 +103,10 @@ spec:
volumeMounts: volumeMounts:
- name: templates - name: templates
mountPath: /app/src/templates mountPath: /app/src/templates
volumes:
- name: templates - name: templates
csi: csi:
driver: gcsfuse.run.googleapis.com driver: gcsfuse.run.googleapis.com
readOnly: true readOnly: true
volumeAttributes: volumeAttributes:
bucketName: templates bucketName: templates