Jenkinsfile
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
pipeline {
agent any
tools {
maven 'maven-3.8'
}
stages {
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('sonarqube') {
sh 'mvn clean compile sonar:sonar'
}
}
}
stage('Quality Gate Check') {
steps {
script {
try {
timeout(time: 15, unit: 'MINUTES') {
waitForQualityGate abortPipeline: false
}
} catch (Exception e) {
echo "⚠️ SonarQube 质量门控检查超时,继续执行构建"
}
}
}
}
stage('Build & Test') {
steps {
sh 'mvn test'
}
post {
always {
junit 'target/surefire-reports/*.xml'
}
}
}
}
post {
always {
echo "Allen的计算器项目构建完成 - 构建号: ${BUILD_NUMBER}"
}
success {
echo "✅ 构建成功!"
}
failure {
echo "❌ 构建失败,请检查日志"
}
}
}