Skip to content

Commit

Permalink
fs
Browse files Browse the repository at this point in the history
  • Loading branch information
KimheangKen committed Nov 1, 2023
1 parent f280a81 commit 297d384
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,45 +68,35 @@ pipeline {
}
}
stage('Code Quality Check via SonarQube') {
steps {
script {
def scannerHome = tool 'sonarqube-scanner'
withSonarQubeEnv("sonarqube-server") {
def scannerCommand = """
${scannerHome}/bin/sonar-scanner -X \
-Dsonar.projectKey=spring-project \
-Dsonar.sources=src/main \
-Dsonar.java.binaries=target/classes \
-Dsonar.host.url=http://34.143.129.86:9000 \
-Dsonar.login=${env.SONARQUBE_TOKEN}
"""
def codeQualityLogs = sh script: scannerCommand, returnStatus: true
steps {
script {
def scannerHome = tool 'sonarqube-scanner'
withSonarQubeEnv("sonarqube-server") {
// Define environment variables securely
def scannerCommand = """
${scannerHome}/bin/sonar-scanner -X\
-Dsonar.projectKey=spring-project \
-Dsonar.sources=src/main \
-Dsonar.java.binaries=target/classes \
-Dsonar.host.url=http://34.143.129.86:9000 \
-Dsonar.login=${env.SONARQUBE_TOKEN}
"""
def codeQualityLogs = sh script: scannerCommand, returnStatus: true

if (codeQualityLogs != 0) {
sendTelegramMessage("❌ Code Quality Check via SonarQube failed")
currentBuild.result = 'FAILURE'
error("Code Quality Check via SonarQube failed")
} else {
echo "✅ Code Quality Check via SonarQube succeeded"

// You can add additional checks here
def qualityGateStatus = sh script: "${scannerHome}/bin/sonar-scanner -X -Dsonar.qualitygate.wait=true -Dsonar.login=${env.SONARQUBE_TOKEN}", returnStatus: true
if (qualityGateStatus != 0) {
sendTelegramMessage("❌ Quality Gate check failed. The build does not meet quality standards.")
currentBuild.result = 'FAILURE'
error("Quality Gate check failed")
} else {
echo "✅ Quality Gate passed. The build meets quality standards."
}
}
if (codeQualityLogs != 0) {
sendTelegramMessage("❌ Code Quality Check via SonarQube failed")
currentBuild.result = 'FAILURE'
error("Code Quality Check via SonarQube failed")
} else {
echo "✅ Code Quality Check via SonarQube succeeded"
}
}
}
}
}




stage('Build') {
steps {
script {
Expand Down

0 comments on commit 297d384

Please sign in to comment.