add cicd pipeline

This commit is contained in:
hiondal 2025-09-30 15:41:08 +09:00
parent d45147b893
commit e21d65ae48
2 changed files with 9 additions and 8 deletions

View File

@ -71,6 +71,7 @@ podTemplate(
def props def props
def imageTag = getImageTag() def imageTag = getImageTag()
def environment = params.ENVIRONMENT ?: 'dev' def environment = params.ENVIRONMENT ?: 'dev'
def id = params.ID ?: 'dg0500'
def skipSonarQube = (params.SKIP_SONARQUBE?.toLowerCase() == 'true') def skipSonarQube = (params.SKIP_SONARQUBE?.toLowerCase() == 'true')
def services = ['api-gateway', 'user-service', 'bill-service', 'product-service', 'kos-mock'] def services = ['api-gateway', 'user-service', 'bill-service', 'product-service', 'kos-mock']
@ -86,7 +87,7 @@ podTemplate(
sh """ sh """
az login --service-principal -u \$AZURE_CLIENT_ID -p \$AZURE_CLIENT_SECRET -t \$AZURE_TENANT_ID az login --service-principal -u \$AZURE_CLIENT_ID -p \$AZURE_CLIENT_SECRET -t \$AZURE_TENANT_ID
az aks get-credentials --resource-group ${props.resource_group} --name ${props.cluster_name} --overwrite-existing az aks get-credentials --resource-group ${props.resource_group} --name ${props.cluster_name} --overwrite-existing
kubectl create namespace phonebill-${environment} --dry-run=client -o yaml | kubectl apply -f - kubectl create namespace phonebill-${id} --dry-run=client -o yaml | kubectl apply -f -
""" """
} }
} }
@ -111,8 +112,8 @@ podTemplate(
services.each { service -> services.each { service ->
sh """ sh """
./gradlew :${service}:test :${service}:jacocoTestReport :${service}:sonar \\ ./gradlew :${service}:test :${service}:jacocoTestReport :${service}:sonar \\
-Dsonar.projectKey=phonebill-${service}-${environment} \\ -Dsonar.projectKey=phonebill-${service}-${id} \\
-Dsonar.projectName=phonebill-${service}-${environment} \\ -Dsonar.projectName=phonebill-${service}-${id} \\
-Dsonar.java.binaries=build/classes/java/main \\ -Dsonar.java.binaries=build/classes/java/main \\
-Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml \\ -Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml \\
-Dsonar.exclusions=**/config/**,**/entity/**,**/dto/**,**/*Application.class,**/exception/** -Dsonar.exclusions=**/config/**,**/entity/**,**/dto/**,**/*Application.class,**/exception/**
@ -158,9 +159,9 @@ podTemplate(
--build-arg BUILD_LIB_DIR="${service}/build/libs" \\ --build-arg BUILD_LIB_DIR="${service}/build/libs" \\
--build-arg ARTIFACTORY_FILE="${service}.jar" \\ --build-arg ARTIFACTORY_FILE="${service}.jar" \\
-f deployment/container/Dockerfile-backend \\ -f deployment/container/Dockerfile-backend \\
-t acrdigitalgarage01.azurecr.io/phonebill/${service}:${environment}-${imageTag} . -t acrdigitalgarage01.azurecr.io/phonebill/${service}:${id}-${imageTag} .
podman push acrdigitalgarage01.azurecr.io/phonebill/${service}:${environment}-${imageTag} podman push acrdigitalgarage01.azurecr.io/phonebill/${service}:${id}-${imageTag}
""" """
} }
} }
@ -185,7 +186,7 @@ podTemplate(
# 이미지 태그 업데이트 # 이미지 태그 업데이트
for service in \$services; do for service in \$services; do
\$HOME/bin/kustomize edit set image acrdigitalgarage01.azurecr.io/phonebill/\$service:${environment}-${imageTag} \$HOME/bin/kustomize edit set image acrdigitalgarage01.azurecr.io/phonebill/\$service:${id}-${imageTag}
done done
# 매니페스트 적용 # 매니페스트 적용
@ -194,7 +195,7 @@ podTemplate(
# 배포 상태 확인 # 배포 상태 확인
echo "Waiting for deployments to be ready..." echo "Waiting for deployments to be ready..."
for service in \$services; do for service in \$services; do
kubectl -n phonebill-${environment} wait --for=condition=available deployment/\$service --timeout=300s kubectl -n phonebill-${id} wait --for=condition=available deployment/\$service --timeout=300s
done done
""" """
} }

View File

@ -8,4 +8,4 @@ spec:
ports: ports:
- port: 80 - port: 80
targetPort: 8080 targetPort: 8080
type: ClusterIP type: ClusterIP