Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Jenkins/CD-Pipeline
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pipeline {
agent any

stages {
stage('Docker Deploy To Container') {
steps {
script{
withDockerRegistry(credentialsId: '<DockerCredential>', toolName: 'docker') {
sh "docker run -d --name shopping -p 8070:8070 <DockerUsername>/shopping:latest"
}
}
}
}
}
}
62 changes: 62 additions & 0 deletions Jenkins/CI-Pipeline
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
pipeline {
agent any

tools{
jdk 'jdk11'
maven 'maven3'
}

environment{
SCANNER_HOME= tool 'sonar-scanner'
}

stages {
stage('Git CheckOut') {
steps {
git branch: 'main', changelog: false, poll: false, url: 'https://github.com/<GithubRepo>'
}
}
stage('Compile using Maven') {
steps {
sh "mvn clean compile"
}
}
stage('Analysis using SonarQube') {
steps {
sh '''
${SCANNER_HOME}/bin/sonar-scanner \
-Dsonar.projectKey=shopping-cart \
-Dsonar.projectName=shopping-cart \
-Dsonar.java.binaries=target/classes \
-Dsonar.host.url=http://20.244.106.132:9000 \
-Dsonar.login=<SonarQubeToken>
'''
}
}
stage('Scan using OWASP') {
steps {
dependencyCheck additionalArguments: '--scan ./', odcInstallation: 'DP'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage('Build usin Maven') {
steps {
sh "mvn clean install -DskipTests=True"
}
}
stage('Build and Push on Docker') {
steps {
withDockerRegistry(credentialsId: '<DockerCredential>', url: 'https://index.docker.io/v1/') {
sh "docker build -t shopping:latest -f docker/Dockerfile ."
sh "docker tag shopping:latest <DockerUsername>/shopping:latest"
sh "docker push <DockerUsername>/shopping:latest"
}
}
}
stage('Trigger CD') {
steps {
build job: 'CD-Pipeline', wait: true
}
}
}
}
79 changes: 79 additions & 0 deletions Jenkins/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 🛒 Ekart - CI Pipeline

This repository implements a **Continuous Integration (CI) pipeline** for a Java-based shopping cart application using Jenkins, Maven, SonarQube, OWASP Dependency-Check, and Docker.

---

## 📦 Tech Stack

- **Jenkins** – Automation server for CI/CD.
- **Maven** – Java build and dependency management.
- **SonarQube** – Static code analysis and quality gate checks.
- **OWASP Dependency-Check** – Detects vulnerabilities in dependencies.
- **Docker** – Containerization for consistent deployments.
- **GitHub** – Source code hosting.
- **Docker Hub** – Image registry for Docker builds.

---

## 🔁 Pipeline Stages

### 1. **Git Checkout**
- Clones the `main` branch from the Ekart repository.

### 2. **Compile using Maven**
- Runs `mvn clean compile` to compile the Java application.

### 3. **SonarQube Analysis**
- Performs static code analysis using SonarQube.
- Publishes quality metrics like code smells, bugs, and coverage.

### 4. **OWASP Dependency-Check**
- Scans project dependencies for known vulnerabilities.
- Generates and publishes a detailed security report.

### 5. **Build using Maven**
- Builds the project and generates the final JAR/WAR.
- Skips running tests in this stage (`-DskipTests=true`).

### 6. **Docker Build & Push**
- Builds a Docker image from the `docker/Dockerfile`.
- Tags and pushes the image to Docker Hub under `<DockerUsername>/shopping:latest`.

### 7. **Trigger CD Pipeline**
- Triggers a downstream CD pipeline (`CD-Pipeline`) to handle deployment.

---

## ⚙️ Prerequisites

Make sure your Jenkins server has the following:

- Java 11 (`jdk11`) installed and configured.
- Maven 3 (`maven3`) installed.
- SonarQube server accessible (e.g., `http://20.244.106.132:9000`).
- SonarQube authentication token stored in Jenkins Credentials.
- Docker installed on the Jenkins agent.
- Docker Hub credentials stored in Jenkins.
- OWASP Dependency-Check plugin installed and configured (`odcInstallation: 'DP'`).

---

## 🔐 Secure Credential Management

- Replace hardcoded SonarQube tokens with Jenkins **Credentials (Secret Text)**.
- Use `withCredentials` block for secure usage in pipeline scripts.

---
![](assets/diagram.png)
![](assets/1.png)
![](assets/7.png)
![](assets/6.png)
![](assets/10.png)
![](assets/5.png)
![](assets/2.png)
![](assets/3.png)
![](assets/4.png)



Binary file added Jenkins/assets/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jenkins/assets/diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Jenkins/assets/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@