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')
|
string(credentialsId: 'AWS_REGION', variable: 'AWS_REGION')
|
||||||
]) {
|
]) {
|
||||||
script {
|
script {
|
||||||
sh '''
|
// Use returnStatus to capture exit code properly
|
||||||
echo "=== Terraform Plan ==="
|
def planExitCode = sh(
|
||||||
|
script: '''
|
||||||
|
echo "=== Terraform Plan ==="
|
||||||
|
|
||||||
terraform plan \
|
terraform plan \
|
||||||
-var="project_name=${PROJECT_NAME}" \
|
-var="project_name=${PROJECT_NAME}" \
|
||||||
-var="environment=${ENVIRONMENT}" \
|
-var="environment=${ENVIRONMENT}" \
|
||||||
-var="aws_region=$AWS_REGION" \
|
-var="aws_region=$AWS_REGION" \
|
||||||
-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 "📋 No changes detected"
|
||||||
echo "📝 Changes detected - plan saved to tfplan"
|
} else if (planExitCode == 2) {
|
||||||
elif [ $PLAN_EXIT_CODE -eq 0 ]; then
|
echo "📝 Changes detected - plan saved to tfplan"
|
||||||
echo "📋 No changes detected"
|
sh 'terraform show -no-color tfplan | grep -E "(Plan:|No changes|Error:)" || true'
|
||||||
else
|
} else {
|
||||||
echo "❌ Plan failed"
|
error("❌ Terraform plan failed with exit code: ${planExitCode}")
|
||||||
exit 1
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user