automated terminal push

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

View File

@@ -436,7 +436,9 @@ 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
def planExitCode = sh(
script: '''
echo "=== Terraform Plan ===" echo "=== Terraform Plan ==="
terraform plan \ terraform plan \
@@ -446,21 +448,19 @@ EOF
-var="image_tag=${IMAGE_TAG}" \ -var="image_tag=${IMAGE_TAG}" \
-out=tfplan \ -out=tfplan \
-detailed-exitcode -detailed-exitcode
''',
returnStatus: true
)
PLAN_EXIT_CODE=$? // Handle exit codes
if (planExitCode == 0) {
if [ $PLAN_EXIT_CODE -eq 2 ]; then
echo "📝 Changes detected - plan saved to tfplan"
elif [ $PLAN_EXIT_CODE -eq 0 ]; then
echo "📋 No changes detected" echo "📋 No changes detected"
else } else if (planExitCode == 2) {
echo "❌ Plan failed" echo "📝 Changes detected - plan saved to tfplan"
exit 1 sh 'terraform show -no-color tfplan | grep -E "(Plan:|No changes|Error:)" || true'
fi } else {
error("❌ Terraform plan failed with exit code: ${planExitCode}")
echo "=== Plan Summary ===" }
terraform show -no-color tfplan | grep -E "(Plan:|No changes|Error:)" || true
'''
// Archive the plan // Archive the plan
archiveArtifacts artifacts: 'tfplan', allowEmptyArchive: true archiveArtifacts artifacts: 'tfplan', allowEmptyArchive: true
@@ -469,7 +469,6 @@ EOF
} }
} }
} }
stage('🚦 Deployment Approval') { stage('🚦 Deployment Approval') {
when { when {
equals expected: 'deploy', actual: params.ACTION equals expected: 'deploy', actual: params.ACTION