automated terminal push
This commit is contained in:
59
infrastructure/foundation/Jenkinsfile
vendored
59
infrastructure/foundation/Jenkinsfile
vendored
@@ -130,52 +130,16 @@ pipeline {
|
|||||||
stage('🔧 Setup Tools') {
|
stage('🔧 Setup Tools') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
// Install Terraform if not available
|
// Verify Terraform is available
|
||||||
sh '''
|
sh '''
|
||||||
|
echo "✅ Checking for Terraform..."
|
||||||
if ! command -v terraform &> /dev/null; then
|
if ! command -v terraform &> /dev/null; then
|
||||||
echo "Installing Terraform ${TF_VERSION}..."
|
echo "❌ Terraform not found. Please install Terraform ${TF_VERSION}"
|
||||||
|
|
||||||
# Check if wget is available
|
|
||||||
if ! command -v wget &> /dev/null; then
|
|
||||||
echo "❌ wget not available. Please install Terraform manually or use a different base image."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download and install Terraform
|
|
||||||
wget -q https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip || {
|
|
||||||
echo "❌ Failed to download Terraform"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
unzip -o terraform_${TF_VERSION}_linux_amd64.zip || {
|
|
||||||
echo "❌ Failed to unzip Terraform"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
chmod +x terraform
|
|
||||||
|
|
||||||
# Try to move to system path, fallback to local
|
|
||||||
if sudo mv terraform /usr/local/bin/ 2>/dev/null; then
|
|
||||||
echo "✅ Terraform installed to /usr/local/bin/"
|
|
||||||
elif mv terraform /tmp/ 2>/dev/null; then
|
|
||||||
export PATH="/tmp:$PATH"
|
|
||||||
echo "✅ Terraform installed to /tmp/ (added to PATH)"
|
|
||||||
else
|
|
||||||
echo "⚠️ Could not install Terraform to system path. Using local copy."
|
|
||||||
export PATH=".:$PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
rm -f terraform_${TF_VERSION}_linux_amd64.zip
|
|
||||||
else
|
|
||||||
echo "✅ Terraform is already installed"
|
echo "✅ Terraform is already installed"
|
||||||
fi
|
terraform version
|
||||||
|
|
||||||
echo "Terraform version:"
|
|
||||||
terraform version || {
|
|
||||||
echo "❌ Terraform installation failed or not accessible"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
// Verify AWS credentials and permissions via Jenkins credential store
|
// Verify AWS credentials and permissions via Jenkins credential store
|
||||||
@@ -211,21 +175,20 @@ pipeline {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
error """
|
error """
|
||||||
❌ AWS Credentials Setup Failed: ${e.getMessage()}
|
❌ AWS Credentials Setup Failed: ${e.getMessage()}
|
||||||
|
|
||||||
🔧 Check these in Jenkins:
|
🔧 Check these in Jenkins:
|
||||||
1. Manage Jenkins → Manage Credentials → Global
|
1. Manage Jenkins → Manage Credentials → Global
|
||||||
2. Verify credential exists: '${params.AWS_CREDENTIALS_ID}' (Type: AWS Credentials)
|
2. Verify credential exists: '${params.AWS_CREDENTIALS_ID}' (Type: AWS Credentials)
|
||||||
3. Verify credential exists: '${params.AWS_REGION_ID}' (Type: Secret text)
|
3. Verify credential exists: '${params.AWS_REGION_ID}' (Type: Secret text)
|
||||||
4. Ensure AWS CLI is installed in Jenkins container
|
4. Ensure AWS CLI is installed in Jenkins container
|
||||||
|
|
||||||
💡 Or run with different credential IDs if yours are named differently.
|
💡 Or run with different credential IDs if yours are named differently.
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('🔍 SonarQube Analysis') {
|
stage('🔍 SonarQube Analysis') {
|
||||||
when {
|
when {
|
||||||
allOf {
|
allOf {
|
||||||
|
|||||||
Reference in New Issue
Block a user