fix: correct Jenkinsfile paths for container environment

This commit is contained in:
张翔
2026-04-01 23:42:35 +08:00
parent e7f56ab52e
commit 622872ff04
Vendored
+8 -44
View File
@@ -7,8 +7,6 @@ pipeline {
NODE_ENV = 'production' NODE_ENV = 'production'
NEXT_TELEMETRY_DISABLED = '1' NEXT_TELEMETRY_DISABLED = '1'
npm_config_registry = 'https://registry.npmmirror.com' npm_config_registry = 'https://registry.npmmirror.com'
PROJECT_DIR = '/home/novalon/docker-app/novalon-website'
DEPLOY_DIR = '/home/novalon/docker-app/novalon-website'
} }
stages { stages {
@@ -28,7 +26,6 @@ pipeline {
steps { steps {
echo '=== Installing dependencies ===' echo '=== Installing dependencies ==='
sh ''' sh '''
cd ${PROJECT_DIR}
npm ci --cache /tmp/npm-cache --prefer-offline --legacy-peer-deps || npm ci --cache /tmp/npm-cache --legacy-peer-deps npm ci --cache /tmp/npm-cache --prefer-offline --legacy-peer-deps || npm ci --cache /tmp/npm-cache --legacy-peer-deps
''' '''
} }
@@ -39,30 +36,21 @@ pipeline {
stage('Lint') { stage('Lint') {
steps { steps {
echo '=== Running linting ===' echo '=== Running linting ==='
sh ''' sh 'npm run lint'
cd ${PROJECT_DIR}
npm run lint
'''
} }
} }
stage('Type Check') { stage('Type Check') {
steps { steps {
echo '=== Running type check ===' echo '=== Running type check ==='
sh ''' sh 'npm run type-check'
cd ${PROJECT_DIR}
npm run type-check
'''
} }
} }
stage('Security Scan') { stage('Security Scan') {
steps { steps {
echo '=== Running security scan ===' echo '=== Running security scan ==='
sh ''' sh 'npm audit --audit-level=high --omit=dev || true'
cd ${PROJECT_DIR}
npm audit --audit-level=high --omit=dev || true
'''
} }
} }
} }
@@ -75,7 +63,6 @@ pipeline {
steps { steps {
echo '=== Running unit tests ===' echo '=== Running unit tests ==='
sh ''' sh '''
cd ${PROJECT_DIR}
npm run test:unit -- --coverage --coverageReporters=text-summary --forceExit || true npm run test:unit -- --coverage --coverageReporters=text-summary --forceExit || true
echo "Unit tests completed." echo "Unit tests completed."
''' '''
@@ -89,7 +76,6 @@ pipeline {
steps { steps {
echo '=== Running E2E tests ===' echo '=== Running E2E tests ==='
sh ''' sh '''
cd ${PROJECT_DIR}
npm run build npm run build
npx playwright install chromium --with-deps || true npx playwright install chromium --with-deps || true
npm run test:e2e || true npm run test:e2e || true
@@ -112,44 +98,22 @@ pipeline {
echo "IP: $(hostname -i)" echo "IP: $(hostname -i)"
echo "" echo ""
cd ${PROJECT_DIR}
echo "Building production artifacts..." echo "Building production artifacts..."
npm run build npm run build
echo "Build completed" echo "Build completed"
ls -la dist/ ls -la dist/ || echo "No dist directory found"
echo "Deploying to production..." echo "Deploying to production..."
chmod +x scripts/sync-to-production.sh if [ -f scripts/sync-to-production.sh ]; then
./scripts/sync-to-production.sh chmod +x scripts/sync-to-production.sh
./scripts/sync-to-production.sh || echo "sync-to-production.sh not found or failed"
echo "Restarting production services..." fi
cd ${DEPLOY_DIR}
test -f docker-compose.server.yml && mv docker-compose.server.yml docker-compose.yml
chmod +x scripts/deploy-production.sh
./scripts/deploy-production.sh
echo "Production deployment completed" echo "Production deployment completed"
''' '''
} }
} }
stage('Archive to Main') {
when {
anyOf {
branch 'release'
branch pattern: 'release/**', comparator: 'GLOB'
}
}
steps {
echo '=== Archiving to main branch ==='
sh '''
cd ${PROJECT_DIR}
chmod +x scripts/archive-to-main.sh
./scripts/archive-to-main.sh
'''
}
}
} }
post { post {