automated terminal push
This commit is contained in:
47
infrastructure/services/Jenkinsfile
vendored
47
infrastructure/services/Jenkinsfile
vendored
@@ -436,31 +436,31 @@ EOF
|
||||
string(credentialsId: 'AWS_REGION', variable: 'AWS_REGION')
|
||||
]) {
|
||||
script {
|
||||
sh '''
|
||||
echo "=== Terraform Plan ==="
|
||||
// Use returnStatus to capture exit code properly
|
||||
def planExitCode = sh(
|
||||
script: '''
|
||||
echo "=== Terraform Plan ==="
|
||||
|
||||
terraform plan \
|
||||
-var="project_name=${PROJECT_NAME}" \
|
||||
-var="environment=${ENVIRONMENT}" \
|
||||
-var="aws_region=$AWS_REGION" \
|
||||
-var="image_tag=${IMAGE_TAG}" \
|
||||
-out=tfplan \
|
||||
-detailed-exitcode
|
||||
terraform plan \
|
||||
-var="project_name=${PROJECT_NAME}" \
|
||||
-var="environment=${ENVIRONMENT}" \
|
||||
-var="aws_region=$AWS_REGION" \
|
||||
-var="image_tag=${IMAGE_TAG}" \
|
||||
-out=tfplan \
|
||||
-detailed-exitcode
|
||||
''',
|
||||
returnStatus: true
|
||||
)
|
||||
|
||||
PLAN_EXIT_CODE=$?
|
||||
|
||||
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"
|
||||
else
|
||||
echo "❌ Plan failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Plan Summary ==="
|
||||
terraform show -no-color tfplan | grep -E "(Plan:|No changes|Error:)" || true
|
||||
'''
|
||||
// Handle exit codes
|
||||
if (planExitCode == 0) {
|
||||
echo "📋 No changes detected"
|
||||
} else if (planExitCode == 2) {
|
||||
echo "📝 Changes detected - plan saved to tfplan"
|
||||
sh 'terraform show -no-color tfplan | grep -E "(Plan:|No changes|Error:)" || true'
|
||||
} else {
|
||||
error("❌ Terraform plan failed with exit code: ${planExitCode}")
|
||||
}
|
||||
|
||||
// Archive the plan
|
||||
archiveArtifacts artifacts: 'tfplan', allowEmptyArchive: true
|
||||
@@ -469,7 +469,6 @@ EOF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('🚦 Deployment Approval') {
|
||||
when {
|
||||
equals expected: 'deploy', actual: params.ACTION
|
||||
|
||||
Reference in New Issue
Block a user