diff --git a/Jenkinsfile b/Jenkinsfile index 767824c..6b7a4c9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,10 +64,10 @@ pipeline { ''' // 设置Maven命令 - env.MVN_CMD = 'mvn' - echo "✅ 构建环境检查完成,Maven命令: ${env.MVN_CMD}" + env.MVN_CMD = 'mvn' echo "✅ 构建环境检查完成,Maven命令: ${env.MVN_CMD}" } - } } + } + } stage('编译') { steps { @@ -75,12 +75,12 @@ pipeline { sh "mvn clean compile -DskipTests=true" } } - - stage('单元测试') { + stage('单元测试') { steps { echo '🧪 运行单元测试...' sh "mvn test" - } post { + } + post { always { script { // 发布测试结果 @@ -92,8 +92,7 @@ pipeline { if (fileExists('target/site/jacoco/jacoco.xml')) { publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')], sourceFileResolver: sourceFiles('STORE_LAST_BUILD') } else if (fileExists('target/jacoco.exec')) { - echo '⚠️ 发现jacoco.exec文件,但推荐使用XML格式的覆盖率报告' - } else { + echo '⚠️ 发现jacoco.exec文件,但推荐使用XML格式的覆盖率报告' } else { echo '⚠️ 未找到JaCoCo覆盖率报告文件' } } @@ -101,7 +100,8 @@ pipeline { } } - stage('代码质量扫描') { steps { + stage('代码质量扫描') { + steps { echo '🔍 运行SonarQube代码扫描...' script { try { @@ -116,9 +116,9 @@ pipeline { echo "✅ SonarQube代码扫描完成" } catch (Exception e) { echo "⚠️ SonarQube扫描失败,继续构建流程: ${e.getMessage()}" - } - } - } } + } } + } + } stage('打包') { steps {