From 531c3c11e8a9f2bcd6c6b1830751d7f51c2c69a7 Mon Sep 17 00:00:00 2001 From: Duvan Rondon Date: Mon, 24 Feb 2025 16:28:02 -0500 Subject: [PATCH] Update firmador intern services --- Jenkinsfile firm int | 89 ++++++++++++++++++++++++ Jenkinsfile copy => Jenkinsfile firm out | 0 service-nest.yml | 33 ++++++--- service-spring.yml | 14 ++-- 4 files changed, 118 insertions(+), 18 deletions(-) create mode 100644 Jenkinsfile firm int rename Jenkinsfile copy => Jenkinsfile firm out (100%) diff --git a/Jenkinsfile firm int b/Jenkinsfile firm int new file mode 100644 index 0000000..a7a1265 --- /dev/null +++ b/Jenkinsfile firm int @@ -0,0 +1,89 @@ +pipeline { + agent any + environment { + CLOUDSDK_CORE_PROJECT = 'siman-448015' + REGION = "us-central1" + CLIENT_EMAIL = 'svfe-api-firmador@siman-448015.iam.gserviceaccount.com' + GCLOUD_CREDS = credentials('gcloud-creds') + CLOUD_RUN_FIRMADOR = 'http://localhost:8013' + } + + stages { + + stage('Clonar Repositorio') { + steps { + git credentialsId: 'token_gitea', + url: 'https://gitea.grupoconsiti.com/duvan_andres/prueba.git', + branch: 'main' + } + } + + stage('Authenticate') { + steps { + withCredentials([file(credentialsId: 'gcloud-creds', variable: 'GCLOUD_CREDS')]) { + sh 'gcloud auth activate-service-account --key-file="$GCLOUD_CREDS"' + } + } + } + + stage('Envs about Firmador') { + steps { + sh ''' + sed -i "s|SERVICE_FIRMADOR_URL|${CLOUD_RUN_FIRMADOR}|g" **.yml + cat service-nest.yml + ''' + } + } + + stage('Deploy to Cloud Run Nest and Spring') { + steps { + script { + def outputNest = sh(script: "gcloud run services replace service-nest.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() + + def cloudRunUrlMatchNest = outputNest =~ /URL:\s+(https:\/\/[^\s]+)/ + def cloudRunUrlMatchLotes = outputSpring =~ /URL:\s+(https:\/\/[^\s]+)/ + + if (cloudRunUrlMatchNest) { + env.CLOUD_RUN_NEST = cloudRunUrlMatchNest[0][1] + } + if (cloudRunUrlMatchLotes) { + env.CLOUD_RUN_LOTES = cloudRunUrlMatchLotes[0][1] + } + } + } + } + + stage('Envs about Nest and Spring') { + steps { + sh ''' + sed -i "s|SERVICE_NEST_URL|${CLOUD_RUN_NEST}|g" **.yml + sed -i "s|SERVICE_LOTES_URL|${CLOUD_RUN_LOTES}|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' + ''' + } + } + + stage('Allow allUsers') { + steps { + sh ''' + gcloud run services add-iam-policy-binding cbii-apigateway-jenkins --region='us-central1' --member='allUsers' --role='roles/run.invoker' + ''' + } + } + } + + post { + always { + sh 'gcloud auth revoke $CLIENT_EMAIL' + } + } +} diff --git a/Jenkinsfile copy b/Jenkinsfile firm out similarity index 100% rename from Jenkinsfile copy rename to Jenkinsfile firm out diff --git a/service-nest.yml b/service-nest.yml index 1ed2973..7c970e9 100644 --- a/service-nest.yml +++ b/service-nest.yml @@ -101,12 +101,29 @@ spec: key: '1' name: ENVIRONMENT volumeMounts: - - name: templates_cbii - mountPath: /app/src/templates - volumes: - name: templates_cbii - csi: - driver: gcsfuse.run.googleapis.com - readOnly: true - volumeAttributes: - bucketName: templates_cbii \ No newline at end of file + mountPath: /app/src/templates + + - name: svfe-api-firmador-1 + image: svfe/svfe-api-firmador:v20230109 + resources: + limits: + cpu: 500m + memory: 256Mi + volumeMounts: + - name: certifados + mountPath: /uploads + + volumes: + - name: certifados + csi: + driver: gcsfuse.run.googleapis.com + readOnly: true + volumeAttributes: + bucketName: certifados_prod + - name: templates_cbii + csi: + driver: gcsfuse.run.googleapis.com + readOnly: true + volumeAttributes: + bucketName: templates_cbii diff --git a/service-spring.yml b/service-spring.yml index 3102a26..017b29e 100644 --- a/service-spring.yml +++ b/service-spring.yml @@ -60,12 +60,13 @@ spec: secretKeyRef: key: '1' name: CRYPTO_NEST_DEV + - name: svfe-api-firmador-1 image: svfe/svfe-api-firmador:v20230109 resources: limits: - cpu: 1000m - memory: 512Mi + cpu: 500m + memory: 256Mi volumeMounts: - name: certifados mountPath: /uploads @@ -75,11 +76,4 @@ spec: driver: gcsfuse.run.googleapis.com readOnly: true volumeAttributes: - bucketName: certifados_prod - - - name: templates - csi: - driver: gcsfuse.run.googleapis.com - readOnly: true - volumeAttributes: - bucketName: templates \ No newline at end of file + bucketName: certifados_prod \ No newline at end of file