automated terminal push
This commit is contained in:
55
Jenkinsfile
vendored
55
Jenkinsfile
vendored
@@ -275,6 +275,43 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Infrastructure Readiness Check') {
|
||||||
|
steps {
|
||||||
|
withCredentials([[
|
||||||
|
$class: 'AmazonWebServicesCredentialsBinding',
|
||||||
|
credentialsId: env.AWS_CRED_ID
|
||||||
|
]]) {
|
||||||
|
script {
|
||||||
|
echo "🔍 SECURITY: Checking if infrastructure is ready for deployment..."
|
||||||
|
|
||||||
|
// Check if ECS service exists
|
||||||
|
def serviceExists = sh(
|
||||||
|
script: '''
|
||||||
|
if aws ecs describe-services --cluster nvhi-atsila-cluster --services nvhi-atsila-cluster-service --region us-east-2 2>/dev/null | grep -q "ACTIVE"; then
|
||||||
|
echo "true"
|
||||||
|
else
|
||||||
|
echo "false"
|
||||||
|
fi
|
||||||
|
''',
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
if (serviceExists == "false") {
|
||||||
|
echo "🚨 SECURITY NOTICE: ECS service not found - forcing infrastructure deployment"
|
||||||
|
echo " This is normal for first deployment or after infrastructure cleanup"
|
||||||
|
env.DEPLOYMENT_TYPE = "INFRASTRUCTURE"
|
||||||
|
currentBuild.description = "INFRASTRUCTURE (auto-detected) | ${env.IMAGE_TAG}"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "📋 SECURITY: Infrastructure readiness assessment completed"
|
||||||
|
echo " ECS Service Exists: ${serviceExists}"
|
||||||
|
echo " Final Deployment Type: ${env.DEPLOYMENT_TYPE}"
|
||||||
|
echo " Security Decision: ${serviceExists == 'true' ? 'Application-only deployment' : 'Infrastructure deployment required'}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stage('Deploy Infrastructure') {
|
stage('Deploy Infrastructure') {
|
||||||
when {
|
when {
|
||||||
expression { env.DEPLOYMENT_TYPE == "INFRASTRUCTURE" }
|
expression { env.DEPLOYMENT_TYPE == "INFRASTRUCTURE" }
|
||||||
@@ -400,8 +437,24 @@ pipeline {
|
|||||||
--container-definitions file://task-definition.json \\
|
--container-definitions file://task-definition.json \\
|
||||||
--region ${AWS_REGION}
|
--region ${AWS_REGION}
|
||||||
|
|
||||||
# Perform zero-downtime rolling deployment
|
# Perform zero-downtime rolling deployment with service check
|
||||||
echo "🔄 Performing secure zero-downtime deployment..."
|
echo "🔄 Performing secure zero-downtime deployment..."
|
||||||
|
|
||||||
|
# Wait for service to be active if it was just created
|
||||||
|
echo "⏳ Ensuring ECS service is ready for deployment..."
|
||||||
|
timeout=300
|
||||||
|
while [ \$timeout -gt 0 ]; do
|
||||||
|
if aws ecs describe-services --cluster ${TF_VAR_cluster_name} --services ${TF_VAR_cluster_name}-service --region ${AWS_REGION} 2>/dev/null | grep -q "ACTIVE"; then
|
||||||
|
echo "✅ ECS service is active and ready"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "⏳ Waiting for ECS service to become active..."
|
||||||
|
sleep 10
|
||||||
|
timeout=\$((timeout-10))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Update the service
|
||||||
aws ecs update-service \\
|
aws ecs update-service \\
|
||||||
--cluster ${TF_VAR_cluster_name} \\
|
--cluster ${TF_VAR_cluster_name} \\
|
||||||
--service ${TF_VAR_cluster_name}-service \\
|
--service ${TF_VAR_cluster_name}-service \\
|
||||||
|
Reference in New Issue
Block a user