Team Member: Hanzhi Zhu, Roxy He
This project implements a CI/CD pipeline using Jenkins, SonarQube, and Hadoop MapReduce on Google Cloud Platform. The pipeline automatically analyzes code quality and, if no blocker issues are found, runs a Hadoop job to count lines in all repository files.
- GCP account with billing enabled
gcloud,terraform,kubectl, andgitinstalled- Fork this repository to your GitHub account
cd terraform
cp terraform.tfvars.example terraform.tfvarsEdit terraform.tfvars with your values:
project_id = "your-gcp-project-id"
region = "us-central1"
zone = "us-central1-a"
github_repo_url = "https://github.com/hanzh1/python-code-disasters"
github_webhook_secret = "your-secure-random-string-here"gcloud auth login
gcloud config set project YOUR_PROJECT_ID
gcloud auth application-default logincd ../scripts
chmod +x deploy-all.sh
./deploy-all.shDeployment takes approximately 10-15 minutes.
After deployment completes:
# Configure kubectl
gcloud container clusters get-credentials jenkins-sonarqube-cluster \
--zone us-central1-a \
--project YOUR_PROJECT_ID
# Get Jenkins URL
JENKINS_IP=$(kubectl get svc jenkins-service -n jenkins -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo "Jenkins: http://${JENKINS_IP}:8080/jenkins"
# Get SonarQube URL
SONARQUBE_IP=$(kubectl get svc sonarqube-service -n sonarqube -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo "SonarQube: http://${SONARQUBE_IP}:9000"- Access Jenkins:
http://${JENKINS_IP}:8080/jenkins - Click on
python-code-analysis - Click "Build Now" to trigger the pipeline
- View results in the console output
To automatically trigger builds on code push:
- In GitHub: Settings → Webhooks → Add webhook
- Configure:
- Payload URL:
http://${JENKINS_IP}:8080/github-webhook/ - Content type:
application/json - Events: "Just the push event"
- Payload URL:
- Click "Add webhook"
- Go to pipeline job → Build number → Console Output
- Scroll to "Display Hadoop Results" stage
cd scripts
python3 view-results.py- With Blocker Issues: Pipeline runs, SonarQube detects blockers, Hadoop job is SKIPPED
- No Blocker Issues: Pipeline runs, SonarQube passes, Hadoop job RUNS and displays line counts
To destroy all resources:
cd terraform
terraform destroy