diff --git a/Jenkinsfile b/Jenkinsfile index cd8225c..3c1e927 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,6 +39,7 @@ pipeline { TF_VAR_aws_region = "${AWS_REGION}" // Enhanced deployment tracking IMAGE_TAG = "v1.0.${BUILD_NUMBER}" + // Initialize deployment type - will be set properly in stages DEPLOYMENT_TYPE = "APPLICATION" // Enterprise settings TF_IN_AUTOMATION = 'true' @@ -318,13 +319,17 @@ pipeline { stage('Deploy Infrastructure') { when { - expression { env.DEPLOYMENT_TYPE == "INFRASTRUCTURE" } + anyOf { + expression { params.FORCE_INFRASTRUCTURE_DEPLOY == true } + expression { env.DEPLOYMENT_TYPE == "INFRASTRUCTURE" } + } } steps { withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: env.AWS_CRED_ID]]) { dir('terraform') { script { - echo "🔍 DEPLOYMENT: Deployment type is ${env.DEPLOYMENT_TYPE}" + echo "🔍 DEPLOYMENT: Force parameter = ${params.FORCE_INFRASTRUCTURE_DEPLOY}" + echo "🔍 DEPLOYMENT: Deployment type = ${env.DEPLOYMENT_TYPE}" echo "🚨 SECURITY NOTICE: Infrastructure deployment requested" echo "🏗️ ARCHITECTURE: Deploying ECS Cluster with SSM access (secure, keyless)" echo "🔐 In production: This would require infrastructure-admin role" @@ -366,7 +371,10 @@ pipeline { stage('Wait for ECS Agents') { when { - expression { env.DEPLOYMENT_TYPE == "INFRASTRUCTURE" } + anyOf { + expression { params.FORCE_INFRASTRUCTURE_DEPLOY == true } + expression { env.DEPLOYMENT_TYPE == "INFRASTRUCTURE" } + } } steps { withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: env.AWS_CRED_ID]]) {