Update Jenkinsfile

This commit is contained in:
John Hanzu Kim 2025-06-16 17:37:45 +09:00 committed by GitHub
parent 0d6f435f68
commit a7a046bf43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,7 +37,6 @@ podTemplate(
namespace = "${props.namespace}" namespace = "${props.namespace}"
} }
stage('Build Application') { stage('Build Application') {
container('gradle') { container('gradle') {
sh """ sh """
@ -49,6 +48,9 @@ podTemplate(
./gradlew :store:clean :store:build -x test ./gradlew :store:clean :store:build -x test
./gradlew :marketing-content:clean :marketing-content:build -x test ./gradlew :marketing-content:clean :marketing-content:build -x test
./gradlew :ai-recommend:clean :ai-recommend:build -x test ./gradlew :ai-recommend:clean :ai-recommend:build -x test
echo "=== 빌드 결과 확인 ==="
find . -name "*.jar" -path "*/build/libs/*"
""" """
} }
} }
@ -63,23 +65,47 @@ podTemplate(
sh "podman login ${props.registry} --username \$USERNAME --password \$PASSWORD" sh "podman login ${props.registry} --username \$USERNAME --password \$PASSWORD"
services.each { service -> services.each { service ->
script {
def buildDir = service // 🔧 핵심 수정: smarketing-java 경로 포함
def buildDir = "smarketing-java/${service}"
def jarFile = "${service}.jar" def jarFile = "${service}.jar"
def fullImageName = "${props.registry}/${props.image_org}/${service}:${imageTag}"
echo "Building image for ${service}: ${fullImageName}"
echo "JAR 파일 경로: ${buildDir}/build/libs/${jarFile}"
// JAR 파일 존재 확인
sh """
echo "=== ${service} JAR 파일 확인 ==="
if [ -f "${buildDir}/build/libs/${jarFile}" ]; then
echo "JAR 파일 발견: ${buildDir}/build/libs/${jarFile}"
ls -la ${buildDir}/build/libs/${jarFile}
else
echo "오류: JAR 파일을 찾을 수 없습니다: ${buildDir}/build/libs/${jarFile}"
echo "실제 존재하는 파일들:"
find . -name "*.jar" -path "*${service}*" || echo "JAR 파일이 없습니다"
exit 1
fi
"""
sh """ sh """
podman build \ echo "=== ${service} 이미지 빌드 ==="
--build-arg BUILD_LIB_DIR="${buildDir}/build/libs" \ podman build \\
--build-arg ARTIFACTORY_FILE="${jarFile}" \ --build-arg BUILD_LIB_DIR="${buildDir}/build/libs" \\
-f smarketing-java/deployment/container/Dockerfile \ --build-arg ARTIFACTORY_FILE="${jarFile}" \\
-t ${props.registry}/${props.image_org}/${service}:${imageTag} . -f smarketing-java/deployment/container/Dockerfile \\
-t ${fullImageName} .
podman push ${props.registry}/${props.image_org}/${service}:${imageTag} echo "=== ${service} 이미지 푸시 ==="
podman push ${fullImageName}
echo "Successfully built and pushed: ${fullImageName}"
""" """
} }
} }
} }
} }
}
stage('Generate & Apply Manifest') { stage('Generate & Apply Manifest') {
container('envsubst') { container('envsubst') {
@ -115,10 +141,10 @@ podTemplate(
kubectl apply -f smarketing-java/deployment/${manifest} kubectl apply -f smarketing-java/deployment/${manifest}
echo "Waiting for deployments to be ready..." echo "Waiting for deployments to be ready..."
kubectl -n ${namespace} wait --for=condition=available smarketing-java/deployment/member --timeout=300s kubectl -n ${namespace} wait --for=condition=available deployment/member --timeout=300s
kubectl -n ${namespace} wait --for=condition=available smarketing-java/deployment/store --timeout=300s kubectl -n ${namespace} wait --for=condition=available deployment/store --timeout=300s
kubectl -n ${namespace} wait --for=condition=available smarketing-java/deployment/marketing-content --timeout=300s kubectl -n ${namespace} wait --for=condition=available deployment/marketing-content --timeout=300s
kubectl -n ${namespace} wait --for=condition=available smarketing-java/deployment/ai-recommend --timeout=300s kubectl -n ${namespace} wait --for=condition=available deployment/ai-recommend --timeout=300s
""" """
} }
} }