From b6d220bf3aed1bb234e95af445e1dd9b56a83dd2 Mon Sep 17 00:00:00 2001 From: lenape Date: Sun, 3 Aug 2025 19:40:27 +0000 Subject: [PATCH] automated terminal push --- infrastructure/foundation/Jenkinsfile | 58 ++++++++++----------------- 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/infrastructure/foundation/Jenkinsfile b/infrastructure/foundation/Jenkinsfile index afc5566..98e59df 100644 --- a/infrastructure/foundation/Jenkinsfile +++ b/infrastructure/foundation/Jenkinsfile @@ -212,49 +212,36 @@ pipeline { script { // Create comprehensive SonarQube configuration writeFile file: 'sonar-project.properties', text: """ -sonar.projectKey=${env.SONAR_PROJECT_KEY} -sonar.projectName=${env.SONAR_PROJECT_NAME} -sonar.projectVersion=${env.SONAR_PROJECT_VERSION} -sonar.sources=. -sonar.sourceEncoding=UTF-8 + sonar.projectKey=${env.SONAR_PROJECT_KEY} + sonar.projectName=${env.SONAR_PROJECT_NAME} + sonar.projectVersion=${env.SONAR_PROJECT_VERSION} + sonar.sources=. + sonar.sourceEncoding=UTF-8 -# Terraform-specific configuration -sonar.terraform.file.suffixes=.tf -sonar.exclusions=**/*.tfstate,**/*.tfstate.backup,**/.terraform/**,**/*.tfplan + # Terraform-specific configuration + sonar.terraform.file.suffixes=.tf + sonar.exclusions=**/*.tfstate,**/*.tfstate.backup,**/.terraform/**,**/*.tfplan -# Include scripts in analysis -sonar.inclusions=**/*.tf,**/*.sh + # Include scripts in analysis + sonar.inclusions=**/*.tf,**/*.sh -# Quality gate settings -sonar.qualitygate.wait=true + # Quality gate settings + sonar.qualitygate.wait=true -# Coverage and duplications -sonar.cpd.exclusions=**/*.tf + # Coverage and duplications + sonar.cpd.exclusions=**/*.tf -# Custom properties for enterprise analysis -sonar.tags=terraform,infrastructure,enterprise-cicd -""" + # Custom properties for enterprise analysis + sonar.tags=terraform,infrastructure,enterprise-cicd + """ // Run SonarQube analysis try { + // Use the installed SonarQube Scanner + def scannerHome = tool name: 'SonarScanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation' + withSonarQubeEnv('SonarQube') { - sh ''' - echo "🔍 Running SonarQube analysis on Terraform infrastructure..." - - # Check if sonar-scanner is available - if command -v sonar-scanner &> /dev/null; then - 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 - ''' + sh "${scannerHome}/bin/sonar-scanner" } } catch (Exception e) { echo "❌ SonarQube analysis failed: ${e.getMessage()}" @@ -275,8 +262,7 @@ sonar.tags=terraform,infrastructure,enterprise-cicd error "Pipeline aborted due to SonarQube failure" } } else { - error "SonarQube analysis failed for ${params.ACTION} action" - } + error "SonarQube analysis failed for ${params.ACTION} action" } } } }