ci: optimize Jenkinsfile — parallel pre-deploy, npm ci, fix rollback composer path

This commit is contained in:
F4ilji
2026-07-06 12:39:40 +05:00
parent 9943f7ab90
commit 9f4dfd9bfc
Vendored
+9 -11
View File
@@ -7,6 +7,8 @@ pipeline {
} }
stages { stages {
stage('Pre-deploy') {
parallel {
stage('Backup Database') { stage('Backup Database') {
steps { steps {
dir("${APP_DIR}") { dir("${APP_DIR}") {
@@ -18,7 +20,6 @@ pipeline {
} }
} }
} }
stage('Cleanup Old Files') { stage('Cleanup Old Files') {
steps { steps {
dir("${APP_DIR}") { dir("${APP_DIR}") {
@@ -26,6 +27,8 @@ pipeline {
} }
} }
} }
}
}
stage('Maintenance Mode') { stage('Maintenance Mode') {
steps { steps {
@@ -49,7 +52,7 @@ pipeline {
stage('Install Dependencies') { stage('Install Dependencies') {
steps { steps {
dir("${APP_DIR}") { 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" echo "Rolling back to $PREV_SHA"
git reset --hard $PREV_SHA git reset --hard $PREV_SHA
docker exec ntspi-php php artisan migrate:rollback --force || true 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 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 docker restart ntspi-nginx ntspi-php ntspi-php-queue
fi fi
''' '''
@@ -85,8 +85,7 @@ pipeline {
stage('Build Frontend') { stage('Build Frontend') {
steps { steps {
dir("${APP_DIR}") { dir("${APP_DIR}") {
sh 'docker exec ntspi-php npm install --legacy-peer-deps' sh 'docker exec ntspi-php sh -c "npm ci --legacy-peer-deps && npm run build"'
sh 'docker exec ntspi-php 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:clear-cached-components
docker exec ntspi-php php artisan filament:optimize-clear docker exec ntspi-php php artisan filament:optimize-clear
docker exec ntspi-php php artisan route:cache docker exec ntspi-php php artisan optimize
docker exec ntspi-php php artisan view:cache
docker exec ntspi-php php artisan icons:cache docker exec ntspi-php php artisan icons:cache
docker exec ntspi-php php artisan filament:cache-components docker exec ntspi-php php artisan filament:cache-components
docker exec ntspi-php php artisan filament:optimize docker exec ntspi-php php artisan filament:optimize
@@ -139,7 +137,7 @@ pipeline {
break break
fi fi
echo "Waiting for app... ($i/30)" echo "Waiting for app... ($i/30)"
sleep 2 sleep 1
done done
''' '''
} }