Skip to content

Extras #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
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
23 changes: 0 additions & 23 deletions .github/workflows/firebase-hosting-merge.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/firebase-hosting-pull-request.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@
.env.production.local

npm-debug.log*
yarn.lock
yarn-debug.log*
yarn-error.log*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.17.0-alpine as builder
FROM node:16.17.0-alpine AS builder
WORKDIR /app
COPY ./package.json .
COPY ./yarn.lock .
Expand Down
133 changes: 133 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
pipeline {
agent any

tools {
nodejs 'NodeJS'
}

environment {
SONARQUBE_SCANNER = tool 'Sonar'
DOCKER_CREDENTIALS = credentials('Docker')
TMDB_CREDENTIALS = credentials('tmdb')
}

stages {
stage('Clean Workspace') {
steps {
echo "Cleaning Workspace..."
cleanWs()
echo 'Workspace cleaned.'
}
}

stage('Clone GitHub Repository') {
steps {
script {
echo 'Cloning GitHub repository...'
git branch: 'main', url: 'https://github.com/Abdullah-0-3/NetflixCloneK8s.git'
}
echo 'Cloning done.'
}
}

stage('SonarQube Quality Analysis') {
steps {
script {
withSonarQubeEnv('Sonar') {
echo 'SonarQube scanner environment configured.'
sh "${SONARQUBE_SCANNER}/bin/sonar-scanner -Dsonar.projectName=NetflixClone -Dsonar.projectKey=NetflixClone"
}
}
echo 'SonarQube analysis started.'
}
}

stage('Install Dependencies') {
steps {
script {
sh 'npm install'
echo 'Dependencies installed.'
}
}
}

stage('OWASP Dependency Check') {
steps {
script {
dependencyCheck additionalArguments: '--scan', odcInstallation: 'dc'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
echo 'OWASP Dependency Check completed.'
}
}
}

stage('SonarQube Gate Analysis') {
steps {
script {
echo 'Waiting for SonarQube gate analysis...'
timeout(time: 2, unit: 'MINUTES'){
waitForQualityGate abortPipeline: false
}

}
}
}

stage('Trivy File System Scan') {
steps {
script {
sh 'trivy fs --quiet --ignore-unfixed --format json . > trivy-fs-scan.txt'
echo 'Trivy file system scan completed.'
}
}
}

stage('Build Docker Image') {
steps {
script {
def imageName = "muhammadabdullahabrar/devops:netflix-clone"
sh "docker build --build-arg TMDB_V3_API_KEY=${TMDB_CREDENTIALS} -t ${imageName} ."
echo 'Docker image built.'
}
}
}

stage('Trivy Image Scan') {
steps {
script {
def imageName = "muhammadabdullahabrar/devops:netflix-clone"
sh "trivy image --quiet --ignore-unfixed --format json ${imageName} > trivy-image-scan.txt"
echo 'Trivy image scan completed.'
}
}
}

stage('Push Image to Docker Hub') {
steps {
withCredentials([usernamePassword(credentialsId: 'Docker', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
script {
def imageName = "muhammadabdullahabrar/devops:netflix-clone"
sh """
set -x
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
docker push ${imageName}
docker logout
"""
}
}
}
}

stage('Send Email with Attachments') {
steps {
emailext(
attachLog: true,
subject: "Netflix Clone Pipeline - Jenkins",
body: """Project: ${env.JOB_NAME} - ${env.BUILD_NUMBER} has been built successfully. Check console output at ${env.BUILD_URL}.""",
to: 'abdullahabrar4843@gmail.com', // Change mail here
attachmentsPattern: 'trivy-fs-scan.txt,trivy-image-scan.txt,dependency-check-report.xml'
)
}
}
}
}
Binary file added Netflix Clone Deployment - DevSecOps Project.pdf
Binary file not shown.
Loading