Skip to content

AnuV6/Automated_CI-CD_pipeline_for_web_application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI/CD Pipeline with Jenkins, SonarQube, Docker, and AWS

This project demonstrates how to build an automated CI/CD pipeline for a web application using Jenkins, SonarQube, Docker, and AWS. Each push to the GitHub repository automatically triggers the pipeline, which builds, tests, analyzes, and deploys the application to an AWS EC2 instance.

Project illustration Jenkins


Table of Contents


Project Overview

This project automates the process of building, testing, analyzing, and deploying a web application every time code is pushed to the specified GitHub branch. The pipeline performs the following:

  • Static Code Analysis with SonarQube to catch bugs and vulnerabilities early.
  • Deployment using Docker on AWS EC2, making the latest application version accessible to end users.

Pipeline Workflow

  1. GitHub: Pushes code changes to a specified branch.
  2. Jenkins: Pulls the latest code and initiates the build and test stages.
  3. SonarQube: Scans code for quality issues.
  4. Docker: Deploys the application for user access.

Prerequisites

  • AWS Account with permissions to create and manage EC2 instances.
  • GitHub Repository with the web application code.
  • Basic Knowledge of Jenkins, SonarQube, Docker, and AWS.

Setup Instructions

1. Launch EC2 Instances

Create three EC2 instances on AWS with a security group that allows all traffic (for demonstration purposes).

  • Jenkins Instance
  • SonarQube Instance
  • Docker Instance

2. Install Jenkins, SonarQube, and Docker

Install the necessary software on each EC2 instance:

  • Jenkins on the first EC2 instance.
  • SonarQube on the second EC2 instance.
  • Docker on the third EC2 instance.

3. Configure SSH Connections

  1. Generate SSH keys on the Jenkins server:
    ssh-keygen -t rsa
  2. Add the public SSH keys to the authorized_keys files on the SonarQube and Docker instances for password-less authentication.

4. Configure Jenkins Plugins and Jobs

  1. Install the SSH2 Easy plugin in Jenkins to manage secure SSH connections.
  2. Set up server groups and sites for Jenkins, SonarQube, and Docker.
  3. Create a Jenkins job:
    • Add the GitHub repository link.
    • Set the branch to build and deploy.
    • Add build steps to copy code from Jenkins to SonarQube and Docker instances.

Pipeline Steps

  1. Code Checkout: Jenkins pulls the latest code from GitHub.
  2. Static Code Analysis: Jenkins sends the code to SonarQube for bug and vulnerability scanning.
  3. Build and Test: Jenkins prepares the application for deployment.
  4. Deployment: If the code passes SonarQube checks, Jenkins deploys it to the Docker container, making it available online.

Usage

  1. Push code to the specified branch in your GitHub repository.
  2. Jenkins automatically starts the pipeline.
  3. SonarQube performs a static code analysis.
  4. If all tests pass, the code is deployed to Docker on AWS EC2.

Contributing

Feel free to submit issues or pull requests for enhancements or bug fixes.


License

This project is licensed under the MIT License.