Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b9c2b87
Update Jenkinsfile1
Bhaluk Jun 9, 2024
9524773
Update Jenkinsfile1
Bhaluk Jun 9, 2024
3f0cb66
Update Jenkinsfile1
Bhaluk Jun 10, 2024
67be658
Update Jenkinsfile1
Bhaluk Jun 10, 2024
481118e
Update Jenkinsfile1
Bhaluk Jun 10, 2024
708e47b
Update Jenkinsfile1
Bhaluk Jun 11, 2024
deff353
Update Jenkinsfile1
Bhaluk Jun 11, 2024
057460f
Update Jenkinsfile1
Bhaluk Jun 11, 2024
a077a3d
Update Jenkinsfile1
Bhaluk Jun 11, 2024
09be82d
Update Jenkinsfile1
Bhaluk Jun 11, 2024
f29a8e3
Update Jenkinsfile1
Bhaluk Jun 11, 2024
daa32c8
Update Jenkinsfile1
Bhaluk Jun 11, 2024
916fb66
Update Jenkinsfile1
Bhaluk Jun 11, 2024
aacddca
Update Jenkinsfile1
Bhaluk Jun 11, 2024
4c967c0
Update Jenkinsfile1
Bhaluk Jun 11, 2024
c36ef33
Update Jenkinsfile1
Bhaluk Jun 11, 2024
569886b
Update Jenkinsfile1
Bhaluk Jun 11, 2024
919b7ea
Update deployment.yaml
Bhaluk Jun 11, 2024
ab61685
Update Jenkinsfile1
Bhaluk Jun 11, 2024
371586d
Update Jenkinsfile1
Bhaluk Jun 13, 2024
60ee53c
Update Jenkinsfile1
Bhaluk Jun 13, 2024
bf88395
Update Jenkinsfile1
Bhaluk Jun 13, 2024
c4a2d9f
Update Jenkinsfile1
Bhaluk Jun 13, 2024
ad59ddb
Update Jenkinsfile1
Bhaluk Jun 14, 2024
5b17135
Update deployment.yaml
Bhaluk Jun 14, 2024
430af11
Update deployment.yaml
Bhaluk Jun 14, 2024
9ae9dfc
Update deployment.yaml
Bhaluk Jun 17, 2024
987b9e0
Update deployment.yaml
Bhaluk Jun 17, 2024
52b2c55
Update deployment.yaml
Bhaluk Jun 17, 2024
0920b19
Update deployment.yaml
Bhaluk Jun 18, 2024
786d882
Update deployment.yaml
Bhaluk Jun 18, 2024
78fc0be
Update deployment.yaml
Bhaluk Jun 18, 2024
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
94 changes: 55 additions & 39 deletions Jenkinsfile1
Original file line number Diff line number Diff line change
@@ -1,84 +1,100 @@
pipeline{
agent any
tools{
pipeline {
agent {
label 'worker'
}
tools {
jdk 'jdk17'
nodejs 'node16'
}
environment {
SCANNER_HOME=tool 'sonar-scanner'
SCANNER_HOME = tool 'sonar-scanner'
}
options {
timestamps() // Enables TimeStamper
}
stages {
stage('clean workspace'){
steps{
stage('Clean Workspace') {
steps {
cleanWs()
}
}
stage('Checkout from Git'){
steps{
git branch: 'main', url: 'https://github.com/AWS-AZURE-Bootcamp5/Devsecops-Project1.git'
stage('Checkout from Git') {
steps {
git branch: 'main', url: 'https://github.com/Bhaluk/Devsecops-Project1.git'
}
}
stage("Sonarqube Analysis "){
steps{
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('sonar-server') {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=Game \
-Dsonar.projectKey=Game '''
sh '''$SCANNER_HOME/bin/sonar-scanner \
-Dsonar.projectName=jenkins \
-Dsonar.projectKey=jenkins'''
}
}
}
stage("quality gate"){
steps {
stage('Quality Gate') {
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token'
timeout(time: 5, unit: 'MINUTES') { // Adjust timeout as needed
waitForQualityGate abortPipeline: false, credentialsId: 'sonar-token'
}
}
}
}
}
stage('Install Dependencies') {
steps {
sh "npm install"
}
}
stage('OWASP FS SCAN') {
stage('OWASP Dependency Check') {
steps {
dependencyCheck additionalArguments: '--scan ./ --disableYarnAudit --disableNodeAudit', odcInstallation: 'DP-Check'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage('TRIVY FS SCAN') {
stage('Trivy File System Scan') {
steps {
sh "trivy fs . > trivyfs.txt"
}
}
stage("Docker Build & Push"){
steps{
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){
sh "docker build -t devsecops_ad ."
sh "docker tag devsecops_ad praveensingam1994/devsecops_ad:latest "
sh "docker push praveensingam1994/devsecops_ad:latest "
stage('Docker Build') {
steps {
sh "docker build -t devsecops_ad ."
sh "docker tag devsecops_ad:latest bhaluk/devsecops_ad:V1.0.2"
}
}
stage('Docker Push') {
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'devops-docker'){
sh "docker push bhaluk/devsecops_ad:V1.0.2"
}
}
}
}
stage("TRIVY"){
steps{
sh "trivy image praveensingam1994/devsecops_ad:latest > trivy.txt"
stage('Trivy Image Scan') {
steps {
sh "trivy image bhaluk/devsecops_ad:latest > trivy.txt"
}
}
stage('Deploy to container'){
steps{
sh 'docker run -d --name 2048 -p 3000:3000 praveensingam1994/devsecops_ad:latest'
stage('Deploy to Container') {
steps {
sh 'docker run -d --name 2049 -p 3000:3000 bhaluk/devsecops_ad:V1.0.2'
}
}
stage('Deploy to kubernets'){
steps{
script{
withKubeConfig(caCertificate: '', clusterName: '', contextName: '', credentialsId: 'k8s', namespace: '', restrictKubeConfigAccess: false, serverUrl: '') {
sh 'kubectl apply -f deployment.yaml'
}
stage('Deploy to Kubernetes') {
steps {
sh 'kubectl apply -f deployment.yaml'
}
}
stage('View Results') {
steps {
echo "Trivy File System Scan Results:"
sh "cat trivyfs.txt"

echo "Trivy Image Scan Results:"
sh "cat trivy.txt"
}
}

}
}
9 changes: 4 additions & 5 deletions deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Deployment
metadata:
name: react-app-deployment
spec:
replicas: 3 # Adjust the number of replicas as needed
replicas: 2 # Adjust the number of replicas as needed
selector:
matchLabels:
app: react-app
Expand All @@ -14,9 +14,9 @@ spec:
spec:
containers:
- name: react-app-container
image: sevenajay/2048:latest # Use your actual Docker image name and tag
image: bhaluk/devsecops_ad:V1.0.1 # Use your actual Docker image name and tag
ports:
- containerPort: 3000 # The port your React app is listening on
- containerPort: 80 # The port your React app is listening on

---
apiVersion: v1
Expand All @@ -29,6 +29,5 @@ spec:
ports:
- protocol: TCP
port: 80 # The port exposed by the service within the cluster
targetPort: 3000 # The port your React app is listening on inside the pod
targetPort: 80 # The port your React app is listening on inside the pod
type: LoadBalancer