修改sonarQube配置
This commit is contained in:
parent
712d36bf22
commit
a76b3148a6
43
Jenkinsfile
vendored
43
Jenkinsfile
vendored
@ -9,8 +9,6 @@ pipeline {
|
|||||||
|
|
||||||
tools {
|
tools {
|
||||||
go 'go' // 使用Jenkins手动配置的Go工具
|
go 'go' // 使用Jenkins手动配置的Go工具
|
||||||
// 修复:使用正确的SonarQube Scanner工具类型
|
|
||||||
'hudson.plugins.sonar.SonarRunnerInstallation' 'sonarQube'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
@ -152,28 +150,25 @@ pipeline {
|
|||||||
echo '🔍 运行SonarQube代码扫描...'
|
echo '🔍 运行SonarQube代码扫描...'
|
||||||
script {
|
script {
|
||||||
try {
|
try {
|
||||||
// 创建SonarQube配置文件
|
// 使用withSonarQubeEnv包裹,自动配置sonar-scanner环境
|
||||||
writeFile file: 'sonar-project.properties', text: """
|
withSonarQubeEnv('sonarQube') {
|
||||||
sonar.projectKey=${SONAR_PROJECT_KEY}
|
sh '''
|
||||||
sonar.projectName=Golang Demo
|
sonar-scanner \
|
||||||
sonar.projectVersion=${BUILD_NUMBER}
|
-Dsonar.projectKey=${SONAR_PROJECT_KEY} \
|
||||||
sonar.sources=.
|
-Dsonar.host.url=${SONAR_HOST_URL} \
|
||||||
sonar.exclusions=**/*_test.go,**/vendor/**,**/*.mod,**/*.sum
|
-Dsonar.login=${SONAR_TOKEN} \
|
||||||
sonar.tests=.
|
-Dsonar.projectName="Golang Demo" \
|
||||||
sonar.test.inclusions=**/*_test.go
|
-Dsonar.projectVersion=${BUILD_NUMBER} \
|
||||||
sonar.test.exclusions=**/vendor/**
|
-Dsonar.sources=. \
|
||||||
sonar.go.coverage.reportPaths=coverage.out
|
-Dsonar.exclusions=**/*_test.go,**/vendor/**,**/*.mod,**/*.sum \
|
||||||
sonar.sourceEncoding=UTF-8
|
-Dsonar.tests=. \
|
||||||
sonar.language=go
|
-Dsonar.test.inclusions=**/*_test.go \
|
||||||
"""
|
-Dsonar.test.exclusions=**/vendor/** \
|
||||||
|
-Dsonar.go.coverage.reportPaths=coverage.out \
|
||||||
// 使用Jenkins配置的SonarQube Scanner工具
|
-Dsonar.sourceEncoding=UTF-8 \
|
||||||
sh """
|
-Dsonar.language=go
|
||||||
sonar-scanner \
|
'''
|
||||||
-Dsonar.projectKey=${SONAR_PROJECT_KEY} \
|
}
|
||||||
-Dsonar.host.url=${SONAR_HOST_URL} \
|
|
||||||
-Dsonar.login=${SONAR_TOKEN}
|
|
||||||
"""
|
|
||||||
echo "✅ SonarQube代码扫描完成"
|
echo "✅ SonarQube代码扫描完成"
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user