fix: 修复Jenkinsfile语法错误和缩进问题

- 修复stages缩进错误
- 修复stage之间缺少换行的问题
- 修复script块中的格式错误
- 确保所有stage都有正确的缩进
This commit is contained in:
wangtianqi 2025-06-23 20:27:15 +08:00
parent 76e1b34f4a
commit 0725abdcb4

21
Jenkinsfile vendored
View File

@ -22,12 +22,12 @@ pipeline {
SONAR_PROJECT_KEY = 'jenkins-demo'
SONAR_TOKEN = 'squ_7e4217cabd0faae6f3b8ee359b3b8e2ac52eb69a'
}
// 使用Jenkins中配置的工具自动安装
tools {
maven 'Maven-3.9.6' // 使用您在Jenkins中配置的Maven名称
// JDK使用容器中已有的不需要额外配置
}
stages {
stage('Checkout') {
steps {
@ -40,10 +40,11 @@ pipeline {
returnStdout: true
).trim()
}
echo "📋 Git提交ID: ${env.GIT_COMMIT_SHORT}"
}
} stage('环境检查') {
}
stage('环境检查') {
steps {
echo '🔍 检查构建环境...'
script {
@ -65,8 +66,8 @@ pipeline {
env.MVN_CMD = 'mvn'
echo "✅ 构建环境检查完成Maven命令: ${env.MVN_CMD}"
}
}
}
} }
stage('编译') {
steps {
echo '🔨 开始编译项目...'
@ -101,10 +102,10 @@ pipeline {
}
}
stage('代码质量扫描') {
steps {
stage('代码质量扫描') { steps {
echo '🔍 运行SonarQube代码扫描...'
script { try {
script {
try {
sh """
mvn sonar:sonar \
-Dsonar.projectKey=${SONAR_PROJECT_KEY} \
@ -118,8 +119,8 @@ pipeline {
echo "⚠️ SonarQube扫描失败继续构建流程: ${e.getMessage()}"
}
}
}
}
} }
stage('打包') {
steps {
echo '📦 开始打包应用程序...'