automated terminal push

This commit is contained in:
lenape
2025-08-06 15:09:10 +00:00
parent b272f1c24e
commit 334c7097b3

View File

@@ -436,31 +436,31 @@ EOF
string(credentialsId: 'AWS_REGION', variable: 'AWS_REGION') string(credentialsId: 'AWS_REGION', variable: 'AWS_REGION')
]) { ]) {
script { script {
sh ''' // Use returnStatus to capture exit code properly
echo "=== Terraform Plan ===" def planExitCode = sh(
script: '''
terraform plan \ echo "=== Terraform Plan ==="
-var="project_name=${PROJECT_NAME}" \
-var="environment=${ENVIRONMENT}" \ terraform plan \
-var="aws_region=$AWS_REGION" \ -var="project_name=${PROJECT_NAME}" \
-var="image_tag=${IMAGE_TAG}" \ -var="environment=${ENVIRONMENT}" \
-out=tfplan \ -var="aws_region=$AWS_REGION" \
-detailed-exitcode -var="image_tag=${IMAGE_TAG}" \
-out=tfplan \
PLAN_EXIT_CODE=$? -detailed-exitcode
''',
if [ $PLAN_EXIT_CODE -eq 2 ]; then returnStatus: true
echo "📝 Changes detected - plan saved to tfplan" )
elif [ $PLAN_EXIT_CODE -eq 0 ]; then
echo "📋 No changes detected" // Handle exit codes
else if (planExitCode == 0) {
echo "❌ Plan failed" echo "📋 No changes detected"
exit 1 } else if (planExitCode == 2) {
fi echo "📝 Changes detected - plan saved to tfplan"
sh 'terraform show -no-color tfplan | grep -E "(Plan:|No changes|Error:)" || true'
echo "=== Plan Summary ===" } else {
terraform show -no-color tfplan | grep -E "(Plan:|No changes|Error:)" || true error("❌ Terraform plan failed with exit code: ${planExitCode}")
''' }
// Archive the plan // Archive the plan
archiveArtifacts artifacts: 'tfplan', allowEmptyArchive: true archiveArtifacts artifacts: 'tfplan', allowEmptyArchive: true
@@ -468,8 +468,7 @@ EOF
} }
} }
} }
} }
stage('🚦 Deployment Approval') { stage('🚦 Deployment Approval') {
when { when {
equals expected: 'deploy', actual: params.ACTION equals expected: 'deploy', actual: params.ACTION