From bb82846d5910f5c63b462426d9d078f8326221e3 Mon Sep 17 00:00:00 2001 From: SEAN Date: Thu, 26 Feb 2026 16:22:48 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Jenkinsfile=20=ED=94=84=EB=A1=A0?= =?UTF-8?q?=ED=8A=B8=20=EB=B9=8C=EB=93=9C=20=EC=86=8C=EC=8A=A4=20=EB=B3=B5?= =?UTF-8?q?=EC=82=AC=20=EB=B0=A9=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 정지된 컨테이너에 docker cp하면 바인드 마운트에 반영되지 않아 호스트 볼륨의 옛날 소스로 빌드되는 문제 해결. 임시 alpine 컨테이너를 통해 호스트 볼륨에 직접 복사하도록 변경. Co-Authored-By: Claude Opus 4.6 --- Jenkinsfile | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fa15483..d878d1a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ def TARGET_FRONT_BUILD = '' def TARGET_RUN_SERVER = '' -def CONTAINER_SRC_PATH = '/src' +def FRONT_HOST_PATH = '/volume1/SPMS/PROJECT/Application/Front' pipeline { agent any @@ -13,7 +13,6 @@ pipeline { echo "Current Branch: ${branchName}" if (branchName == 'develop') { - // develop 브랜치 -> Debug 컨테이너 TARGET_FRONT_BUILD = 'spms-front-build-debug' TARGET_RUN_SERVER = 'spms-run-debug' echo "[DEV Mode] Target: DEBUG Container" @@ -38,19 +37,26 @@ pipeline { } } - // [3단계] 컨테이너로 소스 복사 - stage('Copy to Container') { + // [3단계] 실행 중인 임시 컨테이너를 통해 호스트 볼륨에 소스 복사 + // (정지된 컨테이너에 docker cp하면 바인드 마운트에 반영 안 됨) + stage('Copy to Host Volume') { steps { script { def sourcePath = "${WORKSPACE}/react/." - echo "Copying from ${sourcePath} to ${TARGET_FRONT_BUILD}" - def containerId = sh(script: "docker ps -aqf 'name=${TARGET_FRONT_BUILD}'", returnStdout: true).trim() + echo "Copying source to host volume (${FRONT_HOST_PATH})..." - if (containerId) { - sh "docker cp ${sourcePath} ${TARGET_FRONT_BUILD}:${CONTAINER_SRC_PATH}" - } else { - error "Container ${TARGET_FRONT_BUILD} not found!" - } + sh """ + docker rm -f spms-source-copy 2>/dev/null || true + docker run -d --name spms-source-copy \ + -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') { steps { script { - echo "Starting React Build..." + echo "Starting React Build (npm install + build + deploy)..." sh "docker start -a ${TARGET_FRONT_BUILD}" echo "React Build Complete." }