automated terminal push
This commit is contained in:
58
infrastructure/foundation/Jenkinsfile
vendored
58
infrastructure/foundation/Jenkinsfile
vendored
@@ -212,49 +212,36 @@ pipeline {
|
|||||||
script {
|
script {
|
||||||
// Create comprehensive SonarQube configuration
|
// Create comprehensive SonarQube configuration
|
||||||
writeFile file: 'sonar-project.properties', text: """
|
writeFile file: 'sonar-project.properties', text: """
|
||||||
sonar.projectKey=${env.SONAR_PROJECT_KEY}
|
sonar.projectKey=${env.SONAR_PROJECT_KEY}
|
||||||
sonar.projectName=${env.SONAR_PROJECT_NAME}
|
sonar.projectName=${env.SONAR_PROJECT_NAME}
|
||||||
sonar.projectVersion=${env.SONAR_PROJECT_VERSION}
|
sonar.projectVersion=${env.SONAR_PROJECT_VERSION}
|
||||||
sonar.sources=.
|
sonar.sources=.
|
||||||
sonar.sourceEncoding=UTF-8
|
sonar.sourceEncoding=UTF-8
|
||||||
|
|
||||||
# Terraform-specific configuration
|
# Terraform-specific configuration
|
||||||
sonar.terraform.file.suffixes=.tf
|
sonar.terraform.file.suffixes=.tf
|
||||||
sonar.exclusions=**/*.tfstate,**/*.tfstate.backup,**/.terraform/**,**/*.tfplan
|
sonar.exclusions=**/*.tfstate,**/*.tfstate.backup,**/.terraform/**,**/*.tfplan
|
||||||
|
|
||||||
# Include scripts in analysis
|
# Include scripts in analysis
|
||||||
sonar.inclusions=**/*.tf,**/*.sh
|
sonar.inclusions=**/*.tf,**/*.sh
|
||||||
|
|
||||||
# Quality gate settings
|
# Quality gate settings
|
||||||
sonar.qualitygate.wait=true
|
sonar.qualitygate.wait=true
|
||||||
|
|
||||||
# Coverage and duplications
|
# Coverage and duplications
|
||||||
sonar.cpd.exclusions=**/*.tf
|
sonar.cpd.exclusions=**/*.tf
|
||||||
|
|
||||||
# Custom properties for enterprise analysis
|
# Custom properties for enterprise analysis
|
||||||
sonar.tags=terraform,infrastructure,enterprise-cicd
|
sonar.tags=terraform,infrastructure,enterprise-cicd
|
||||||
"""
|
"""
|
||||||
|
|
||||||
// Run SonarQube analysis
|
// Run SonarQube analysis
|
||||||
try {
|
try {
|
||||||
withSonarQubeEnv('SonarQube') {
|
// Use the installed SonarQube Scanner
|
||||||
sh '''
|
def scannerHome = tool name: 'SonarScanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation'
|
||||||
echo "🔍 Running SonarQube analysis on Terraform infrastructure..."
|
|
||||||
|
|
||||||
# Check if sonar-scanner is available
|
withSonarQubeEnv('SonarQube') {
|
||||||
if command -v sonar-scanner &> /dev/null; then
|
sh "${scannerHome}/bin/sonar-scanner"
|
||||||
sonar-scanner
|
|
||||||
else
|
|
||||||
echo "⚠️ sonar-scanner not found. Attempting to use docker fallback..."
|
|
||||||
if command -v docker &> /dev/null; then
|
|
||||||
docker run --rm -v "$(pwd):/usr/src" sonarsource/sonar-scanner-cli
|
|
||||||
else
|
|
||||||
echo "❌ Neither sonar-scanner nor docker available"
|
|
||||||
echo "Please install SonarQube Scanner or skip SonarQube analysis"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
'''
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
echo "❌ SonarQube analysis failed: ${e.getMessage()}"
|
echo "❌ SonarQube analysis failed: ${e.getMessage()}"
|
||||||
@@ -275,8 +262,7 @@ sonar.tags=terraform,infrastructure,enterprise-cicd
|
|||||||
error "Pipeline aborted due to SonarQube failure"
|
error "Pipeline aborted due to SonarQube failure"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error "SonarQube analysis failed for ${params.ACTION} action"
|
error "SonarQube analysis failed for ${params.ACTION} action" }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user