automated terminal push

This commit is contained in:
lenape
2025-07-15 05:38:19 +00:00
parent 48f08905db
commit d3666b6918

23
Jenkinsfile vendored
View File

@@ -82,19 +82,22 @@ pipeline {
echo "✅ Terraform backend created successfully" echo "✅ Terraform backend created successfully"
} else { } else {
echo "⚠️ Terraform apply failed, checking if resources already exist..." echo "⚠️ Terraform apply failed, checking if resources already exist..."
def bucketCheck = sh( def bucketExists = sh(
script: "aws s3api head-bucket --bucket ${TF_BACKEND_BUCKET} --region ${TF_VAR_aws_region} 2>/dev/null && echo 'exists' || echo 'missing'", script: "aws s3api head-bucket --bucket ${TF_BACKEND_BUCKET} --region ${TF_VAR_aws_region} 2>/dev/null",
returnStdout: true returnStatus: true
).trim() ) == 0
def tableCheck = sh( def tableExists = sh(
script: "aws dynamodb describe-table --table-name ${TF_DDB_TABLE} --region ${TF_VAR_aws_region} 2>/dev/null && echo 'exists' || echo 'missing'", script: "aws dynamodb describe-table --table-name ${TF_DDB_TABLE} --region ${TF_VAR_aws_region} 2>/dev/null",
returnStdout: true returnStatus: true
).trim() ) == 0
if (bucketCheck == "exists" && tableCheck == "exists") { if (bucketExists && tableExists) {
echo "✅ Terraform backend already exists - continuing..." echo "✅ Terraform backend already exists - continuing..."
} else { } else {
error("❌ Backend bootstrap failed and resources don't exist. Manual intervention required.") echo "❌ Backend bootstrap failed and resources don't exist:"
echo " S3 Bucket exists: ${bucketExists}"
echo " DynamoDB Table exists: ${tableExists}"
error("Manual intervention required.")
} }
} }
} }