fix: Jenkinsfile 프론트 빌드 소스 복사 방식 수정
Some checks failed
SPMS_BO/pipeline/head There was a failure building this commit

정지된 컨테이너에 docker cp하면 바인드 마운트에 반영되지 않아
호스트 볼륨의 옛날 소스로 빌드되는 문제 해결.
임시 alpine 컨테이너를 통해 호스트 볼륨에 직접 복사하도록 변경.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
SEAN 2026-02-26 16:22:48 +09:00
parent e8edbb528c
commit bb82846d59

30
Jenkinsfile vendored
View File

@ -1,6 +1,6 @@
def TARGET_FRONT_BUILD = '' def TARGET_FRONT_BUILD = ''
def TARGET_RUN_SERVER = '' def TARGET_RUN_SERVER = ''
def CONTAINER_SRC_PATH = '/src' def FRONT_HOST_PATH = '/volume1/SPMS/PROJECT/Application/Front'
pipeline { pipeline {
agent any agent any
@ -13,7 +13,6 @@ pipeline {
echo "Current Branch: ${branchName}" echo "Current Branch: ${branchName}"
if (branchName == 'develop') { if (branchName == 'develop') {
// develop 브랜치 -> Debug 컨테이너
TARGET_FRONT_BUILD = 'spms-front-build-debug' TARGET_FRONT_BUILD = 'spms-front-build-debug'
TARGET_RUN_SERVER = 'spms-run-debug' TARGET_RUN_SERVER = 'spms-run-debug'
echo "[DEV Mode] Target: DEBUG Container" echo "[DEV Mode] Target: DEBUG Container"
@ -38,19 +37,26 @@ pipeline {
} }
} }
// [3단계] 컨테이너로 소스 복사 // [3단계] 실행 중인 임시 컨테이너를 통해 호스트 볼륨에 소스 복사
stage('Copy to Container') { // (정지된 컨테이너에 docker cp하면 바인드 마운트에 반영 안 됨)
stage('Copy to Host Volume') {
steps { steps {
script { script {
def sourcePath = "${WORKSPACE}/react/." def sourcePath = "${WORKSPACE}/react/."
echo "Copying from ${sourcePath} to ${TARGET_FRONT_BUILD}" echo "Copying source to host volume (${FRONT_HOST_PATH})..."
def containerId = sh(script: "docker ps -aqf 'name=${TARGET_FRONT_BUILD}'", returnStdout: true).trim()
if (containerId) { sh """
sh "docker cp ${sourcePath} ${TARGET_FRONT_BUILD}:${CONTAINER_SRC_PATH}" docker rm -f spms-source-copy 2>/dev/null || true
} else { docker run -d --name spms-source-copy \
error "Container ${TARGET_FRONT_BUILD} not found!" -v ${FRONT_HOST_PATH}:/target \
} alpine sleep 30
docker exec spms-source-copy sh -c \
'find /target -mindepth 1 -maxdepth 1 ! -name node_modules -exec rm -rf {} +'
docker cp ${sourcePath} spms-source-copy:/target/
docker rm -f spms-source-copy
"""
echo "Source copy complete."
} }
} }
} }
@ -58,7 +64,7 @@ pipeline {
stage('Build Frontend') { stage('Build Frontend') {
steps { steps {
script { script {
echo "Starting React Build..." echo "Starting React Build (npm install + build + deploy)..."
sh "docker start -a ${TARGET_FRONT_BUILD}" sh "docker start -a ${TARGET_FRONT_BUILD}"
echo "React Build Complete." echo "React Build Complete."
} }