diff --git a/infrastructure/foundation/Jenkinsfile b/infrastructure/foundation/Jenkinsfile index 1e0c720..afc5566 100644 --- a/infrastructure/foundation/Jenkinsfile +++ b/infrastructure/foundation/Jenkinsfile @@ -132,14 +132,24 @@ pipeline { script { // Verify Terraform is available sh ''' - echo "✅ Checking for Terraform..." - if command -v terraform > /dev/null 2>&1; then - echo "❌ Terraform not found. Please install Terraform ${TF_VERSION}" + echo "=== Tool Validation ===" + + # Validate Terraform with version check + if terraform version > /dev/null 2>&1; then + TF_VERSION_ACTUAL=$(terraform version | head -n1 | cut -d' ' -f2 | sed 's/^v//') + echo "✅ Terraform found: v${TF_VERSION_ACTUAL}" + + # Ensure minimum version + if [ "${TF_VERSION_ACTUAL}" != "${TF_VERSION}" ]; then + echo "⚠️ Note: Expected v${TF_VERSION}, found v${TF_VERSION_ACTUAL}" + fi + else + echo "❌ Terraform not found (required: v${TF_VERSION})" + echo " Install: https://releases.hashicorp.com/terraform/${TF_VERSION}/" exit 1 fi - echo "✅ Terraform is already installed" - terraform version + echo "=== Tool Validation Complete ===" ''' // Verify AWS credentials and permissions via Jenkins credential store @@ -189,6 +199,7 @@ pipeline { } } } + stage('🔍 SonarQube Analysis') { when { allOf {