KIM-JINO5 2 месяцев назад
Родитель
Сommit
22a0d1ee1f
1 измененных файлов с 23 добавлено и 2 удалено
  1. 23 2
      Jenkinsfile

+ 23 - 2
Jenkinsfile

@@ -4,9 +4,31 @@ pipeline {
         DEPLOY_FRONTEND = '/mnt/h/bitforum/sources'
     }
     stages {
+        stage('Install') {
+            steps {
+                script {
+                    // package-lock.json 해시 비교해서 변경됐을 때만 재설치
+                    def lockHash = sh(
+                        script: 'sha256sum package-lock.json | cut -d" " -f1',
+                        returnStdout: true
+                    ).trim()
+                    def cacheFile = '.npm-lock-hash'
+                    def prevHash = fileExists(cacheFile)
+                        ? readFile(cacheFile).trim()
+                        : ''
+
+                    if (lockHash != prevHash) {
+                        echo "package-lock.json 변경 감지 → npm ci 실행"
+                        sh 'npm ci'
+                        writeFile file: cacheFile, text: lockHash
+                    } else {
+                        echo "package-lock.json 변경 없음 → 설치 스킵"
+                    }
+                }
+            }
+        }
         stage('Build') {
             steps {
-                sh 'npm ci --prefer-offline'
                 sh 'npm run build'
             }
         }
@@ -18,7 +40,6 @@ pipeline {
                         --exclude="ecosystem.config.js" \
                         --exclude="restart.ps1" \
                         --exclude=".env*" \
-                        --exclude="node_modules/.cache" \
                         .next/standalone/ ${DEPLOY_FRONTEND}/
                 '''
                 sh 'rsync -a --stats --delete .next/static/ ${DEPLOY_FRONTEND}/.next/static/'