This project sets up a complete CI/CD pipeline using Jenkins, Docker, Azure Kubernetes Service (AKS), SonarQube, and Vercel. The pipeline automatically triggers on every commit to the GitHub repository and performs code analysis, builds Docker images, deploys to AKS, and triggers a deployment to Vercel.
.
├── backend
│ ├── Dockerfile
│ ├── src
│ └── ...
├── frontend
│ ├── Dockerfile
│ ├── src
│ └── ...
├── deployment.yaml
├── service.yaml
├── Jenkinsfile
└── README.md
- Jenkins: Installed and running.
- Docker: Installed and configured.
- Azure CLI: Installed and configured.
- GitHub Repository: Set up with webhook to trigger Jenkins.
- SonarQube: Set up and running.
- Vercel Account: Set up and project created.
- Go to your GitHub repository settings.
- Click on "Webhooks" and then "Add webhook".
- Set the Payload URL to
http://your-jenkins-url/github-webhook/. - Choose
application/jsonas the content type. - Select "Just the push event".
- Click "Add webhook".
- Install the necessary plugins: GitHub Integration Plugin, Docker Plugin, Kubernetes Plugin, etc.
- Create a new Pipeline job and set it to use the
Jenkinsfilefrom SCM.
The Jenkinsfile is already set up in the repository. It defines the following stages:
- Checkout: Clones the repository and retrieves the commit hash.
- SonarQube Analysis: Performs static code analysis for both backend and frontend.
- Build Docker Images: Builds Docker images for backend and frontend.
- Docker Login: Logs into Docker Hub.
- Push Docker Images: Pushes the built images to Docker Hub.
- Azure Login: Logs into Azure using service principal credentials.
- Get AKS Credentials: Retrieves AKS credentials for deployment.
- Deploy to AKS: Deploys Docker images to AKS.
- Deploy to Vercel: Triggers a deployment to Vercel and checks the status.
Ensure the following credentials and environment variables are set up in Jenkins:
dockerhub-credentials: Docker Hub credentials.sonar-token: SonarQube authentication token.azure-credentials: Azure service principal credentials.vercel-token: Vercel authentication token.
The deployment.yaml and service.yaml files define the Kubernetes deployment and service configurations.
Trigger the Vercel deployment using the provided deployment hook.
The post section in the Jenkinsfile ensures cleanup of Docker resources after the pipeline execution.
- Commit changes to the GitHub repository.
- The Jenkins pipeline will automatically trigger and execute all stages.
- The project will be deployed to AKS and Vercel.
- Monitor the build and deployment status on Jenkins.
