Skip to content
Snippets Groups Projects
Commit b162036d authored by Abdellatif Kebraoui's avatar Abdellatif Kebraoui
Browse files

[FEAT] enhance GitLab CI configuration with test stage and SonarCloud check;...

[FEAT] enhance GitLab CI configuration with test stage and SonarCloud check; remove Eureka dependencies from pom.xml and update application configuration
parent c394186e
No related branches found
No related tags found
No related merge requests found
stages: stages:
- build - build
- test
- deploy - deploy
# Build stage # Build stage
...@@ -13,30 +14,24 @@ build-job: ...@@ -13,30 +14,24 @@ build-job:
paths: paths:
- target/*.jar - target/*.jar
# Test stage
test-job:
stage: test
image: maven:3.9-eclipse-temurin-21
script:
- chmod +x ./mvnw
- ./mvnw test
# Deploy stage # Deploy stage
deploy-prod: deploy-prod:
stage: deploy stage: deploy
image: google/cloud-sdk:alpine image: google/cloud-sdk:alpine
script: | script:
# Decode the service key and authenticate - echo "$GCP_SERVICE_KEY" | base64 -d > gcp-key.json
echo "$GCP_SERVICE_KEY" | base64 -d > gcp-key.json - gcloud auth activate-service-account --key-file=gcp-key.json
gcloud auth activate-service-account --key-file=gcp-key.json - gcloud config set project $PROJECT_ID
gcloud config set project $PROJECT_ID - gcloud builds submit --tag gcr.io/$PROJECT_ID/$SERVICE_NAME:latest .
- gcloud run deploy $SERVICE_NAME --image gcr.io/$PROJECT_ID/$SERVICE_NAME:latest --platform managed --region $REGION --allow-unauthenticated --vpc-connector=glop-connector --quiet
# Deploy the service using the defined SERVICE_NAME variable
gcloud run deploy $SERVICE_NAME \
--image=gcr.io/$PROJECT_ID/$SERVICE_NAME:latest \
--platform managed \
--region $REGION \
--allow-unauthenticated \
--memory=512Mi \
--min-instances=1 \
--cpu=1 \
--timeout=300 \
--vpc-connector=glop-connector \
--set-env-vars SPRING_PROFILES_ACTIVE=cloud \
--ingress=all \
--no-cpu-throttling
environment: environment:
name: production name: production
url: https://$SERVICE_NAME-$REGION.run.app url: https://$SERVICE_NAME-$REGION.run.app
...@@ -45,8 +40,22 @@ deploy-prod: ...@@ -45,8 +40,22 @@ deploy-prod:
- main - main
- deploy - deploy
# SonarCloud check
sonarcloud-check:
image: maven:3.9-eclipse-temurin-21
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- mvn verify sonar:sonar -Dsonar.projectKey=gitlab-univ-2_miage-glop-user-management
only:
- merge_requests
- main
variables: variables:
GIT_DEPTH: "0" GIT_DEPTH: "0"
PROJECT_ID: "mobisurmoinsdeco2" PROJECT_ID: "mobisurmoinsdeco2"
#todo: change this
SERVICE_NAME: "usermanagement-service" SERVICE_NAME: "usermanagement-service"
REGION: "europe-west1" REGION: "europe-west1"
...@@ -88,11 +88,6 @@ ...@@ -88,11 +88,6 @@
<groupId>jakarta.validation</groupId> <groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId> <artifactId>jakarta.validation-api</artifactId>
</dependency> </dependency>
<!-- Eureka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -16,34 +16,10 @@ spring: ...@@ -16,34 +16,10 @@ spring:
ddl-auto: update ddl-auto: update
properties: properties:
hibernate: hibernate:
format_sql: true "[format_sql]": true
show-sql: true show-sql: true
eureka:
instance:
prefer-ip-address: false
hostname: usermanagement-service-682610574114.europe-west1.run.app
instanceId: ${spring.application.name}:${random.uuid}
securePortEnabled: true
nonSecurePortEnabled: false
securePort: ${server.port}
homePageUrl: https://${eureka.instance.hostname}/
statusPageUrl: https://${eureka.instance.hostname}/actuator/info
healthCheckUrl: https://${eureka.instance.hostname}/actuator/health
appname: ${spring.application.name}
lease-renewal-interval-in-seconds: 30
metadataMap:
instanceId: ${spring.application.name}:${random.uuid}
client:
serviceUrl:
defaultZone: https://eureka:${EUREKA_PASSWORD:password}@eureka-service-682610574114.europe-west1.run.app/eureka/
register-with-eureka: true
fetch-registry: true
registryFetchIntervalSeconds: 5
use-secure-port: true
# Added for troubleshooting # Added for troubleshooting
logging: logging:
level: level:
com.netflix.discovery: DEBUG "[org.springframework.web.client.RestTemplate]": DEBUG
org.springframework.web.client.RestTemplate: DEBUG \ No newline at end of file
\ No newline at end of file
...@@ -22,16 +22,3 @@ spring: ...@@ -22,16 +22,3 @@ spring:
server: server:
port: 8082 port: 8082
# URL du serveur Eureka
eureka:
instance:
prefer-ip-address: true
ip-address: 127.0.0.1
hostname: localhost
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
register-with-eureka: true
fetch-registry: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment