Files
novalon-website/Jenkinsfile
T
张翔 042f66499a fix: complete test suite fixes - achieve 99.8% pass rate
- Add missing lucide-react icons (Users, Target, MessageCircle, Layers, CreditCard)
- Fix admin/page.test.tsx ESLint errors (add displayName)
- Fix api/contact/route.test.ts ESLint errors (remove any types, use import)
- Add RESEND_API_KEY environment variable for API tests
- All 122 test suites now passing
- Test pass rate: 99.8% (1499/1502 passed, 3 skipped)
2026-04-09 17:33:21 +08:00

170 lines
5.0 KiB
Groovy

pipeline {
agent {
label 'master'
}
environment {
NODE_ENV = 'production'
NEXT_TELEMETRY_DISABLED = '1'
npm_config_registry = 'https://registry.npmmirror.com'
JENKINS_WEBHOOK_TOKEN = credentials('jenkins-webhook-token')
}
triggers {
GenericTrigger(
genericVariables: [
[key: 'ref', value: '$.ref']
],
genericRequestVariables: [
[key: 'ref', regexpFilter: ''],
[key: 'repository.name', regexpFilter: '']
],
genericHeaderVariables: [
[key: 'X-Gitea-Event', regexpFilter: ''],
[key: 'X-Gitea-Signature', regexpFilter: '']
],
causeString: 'Gitea Webhook Trigger: $ref',
token: env.JENKINS_WEBHOOK_TOKEN,
printContributedVariables: true,
printPostContent: false,
silentResponse: false,
shouldNotFlatten: false,
regexpFilterText: '$ref',
regexpFilterExpression: '^refs/heads/release/.*$'
)
pollSCM('H/5 * * * *')
}
stages {
stage('Checkout') {
steps {
echo '=== Checking out code from Gitea ==='
checkout scm
sh '''
echo "Current branch: ${BRANCH_NAME}"
echo "Commit: ${GIT_COMMIT}"
echo "Workspace: ${WORKSPACE}"
'''
}
}
stage('Install Dependencies') {
steps {
echo '=== Installing dependencies ==='
sh '''
npm ci --cache /tmp/npm-cache --prefer-offline --legacy-peer-deps || npm ci --cache /tmp/npm-cache --legacy-peer-deps
'''
}
}
stage('Code Quality Check') {
parallel {
stage('Lint') {
steps {
echo '=== Running linting ==='
sh 'npm run lint'
}
}
stage('Type Check') {
steps {
echo '=== Running type check ==='
sh 'npm run type-check'
}
}
stage('Security Scan') {
steps {
echo '=== Running security scan ==='
sh 'npm audit --audit-level=high --omit=dev || true'
}
}
}
}
stage('Unit Tests') {
when {
branch 'dev'
}
steps {
echo '=== Running unit tests ==='
sh '''
npm run test:unit -- --coverage --coverageReporters=text-summary --forceExit || true
echo "Unit tests completed."
'''
}
}
stage('E2E Tests') {
when {
branch 'dev'
}
steps {
echo '=== Running E2E tests ==='
sh '''
npm run build
npx playwright install chromium --with-deps || true
npm run test:e2e || true
'''
}
}
stage('Build and Deploy') {
when {
anyOf {
branch 'release'
branch pattern: 'release/**', comparator: 'GLOB'
}
}
steps {
echo '=== Building and deploying to production ==='
sh '''
echo "Current container info:"
echo "Hostname: $(hostname)"
echo "IP: $(hostname -i)"
echo ""
echo "Building production artifacts..."
npm run build
echo "Build completed"
ls -la dist/ || echo "No dist directory found"
echo "Deploying to production..."
if [ -f scripts/sync-to-production.sh ]; then
chmod +x scripts/sync-to-production.sh
./scripts/sync-to-production.sh || echo "sync-to-production.sh not found or failed"
fi
echo "Production deployment completed"
'''
}
}
}
post {
success {
echo '=== Build succeeded! ==='
script {
if (env.BRANCH_NAME.startsWith('release')) {
echo 'Sending success notification to WeChat...'
}
}
}
failure {
echo '=== Build failed! ==='
script {
if (env.BRANCH_NAME.startsWith('release')) {
echo 'Sending failure notification to WeChat...'
}
}
}
always {
echo '=== Cleaning up workspace ==='
cleanWs()
}
}
}