From 9f4dfd9bfcaaec75ea7cd3faf4529ff15ace4dd5 Mon Sep 17 00:00:00 2001 From: F4ilji Date: Mon, 6 Jul 2026 12:39:40 +0500 Subject: [PATCH] =?UTF-8?q?ci:=20optimize=20Jenkinsfile=20=E2=80=94=20para?= =?UTF-8?q?llel=20pre-deploy,=20npm=20ci,=20fix=20rollback=20composer=20pa?= =?UTF-8?q?th?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ce8a65e..117db11 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,22 +7,25 @@ pipeline { } stages { - stage('Backup Database') { - steps { - dir("${APP_DIR}") { - sh ''' - mkdir -p backups - docker exec ntspi-db mysqldump -u admin -psecret ntspi_db | gzip > backups/ntspi_db_$(date +%F_%H%M).sql.gz - find backups -name "*.sql.gz" -mtime +3 -delete - ''' + stage('Pre-deploy') { + parallel { + stage('Backup Database') { + steps { + dir("${APP_DIR}") { + sh ''' + mkdir -p backups + docker exec ntspi-db mysqldump -u admin -psecret ntspi_db | gzip > backups/ntspi_db_$(date +%F_%H%M).sql.gz + find backups -name "*.sql.gz" -mtime +3 -delete + ''' + } + } } - } - } - - stage('Cleanup Old Files') { - steps { - dir("${APP_DIR}") { - sh 'docker exec ntspi-php find /var/www/storage/app/email_attachments -type f -mtime +3 -delete' + stage('Cleanup Old Files') { + steps { + dir("${APP_DIR}") { + sh 'docker exec ntspi-php find /var/www/storage/app/email_attachments -type f -mtime +3 -delete' + } + } } } } @@ -49,7 +52,7 @@ pipeline { stage('Install Dependencies') { steps { dir("${APP_DIR}") { - sh 'docker exec ntspi-php php -d open_basedir=none /usr/local/bin/composer install --no-dev --no-interaction --prefer-dist --no-cache' + sh 'docker exec ntspi-php php -d open_basedir=none /usr/local/bin/composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader' } } } @@ -69,11 +72,8 @@ pipeline { echo "Rolling back to $PREV_SHA" git reset --hard $PREV_SHA docker exec ntspi-php php artisan migrate:rollback --force || true - docker exec ntspi-php composer install --no-dev --no-interaction --prefer-dist --no-cache + docker exec ntspi-php sh -c "php -d open_basedir=none /usr/local/bin/composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader" docker exec ntspi-php php artisan cache:clear - docker exec ntspi-php php artisan config:clear - docker exec ntspi-php php artisan route:clear - docker exec ntspi-php php artisan view:clear docker restart ntspi-nginx ntspi-php ntspi-php-queue fi ''' @@ -85,8 +85,7 @@ pipeline { stage('Build Frontend') { steps { dir("${APP_DIR}") { - sh 'docker exec ntspi-php npm install --legacy-peer-deps' - sh 'docker exec ntspi-php npm run build' + sh 'docker exec ntspi-php sh -c "npm ci --legacy-peer-deps && npm run build"' } } } @@ -102,8 +101,7 @@ pipeline { docker exec ntspi-php php artisan filament:clear-cached-components docker exec ntspi-php php artisan filament:optimize-clear - docker exec ntspi-php php artisan route:cache - docker exec ntspi-php php artisan view:cache + docker exec ntspi-php php artisan optimize docker exec ntspi-php php artisan icons:cache docker exec ntspi-php php artisan filament:cache-components docker exec ntspi-php php artisan filament:optimize @@ -139,7 +137,7 @@ pipeline { break fi echo "Waiting for app... ($i/30)" - sleep 2 + sleep 1 done ''' }