-
Notifications
You must be signed in to change notification settings - Fork 305
/
Copy pathjenkinsfile
108 lines (108 loc) · 3.52 KB
/
jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
pipeline {
agent any
tools {
jdk 'jdk17'
nodejs 'node23'
}
environment {
SCANNER_HOME=tool 'sonar-scanner'
}
stages {
stage ("clean workspace") {
steps {
cleanWs()
}
}
stage ("Git Checkout") {
steps {
git 'https://github.com/KastroVKiran/Zomato-Project-Kastro.git'
}
}
stage("Sonarqube Analysis"){
steps{
withSonarQubeEnv('sonar-server') {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=zomato \
-Dsonar.projectKey=zomato '''
}
}
}
stage("Code Quality Gate"){
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token'
}
}
}
stage("Install NPM Dependencies") {
steps {
sh "npm install"
}
}
stage('OWASP FS SCAN') {
steps {
dependencyCheck additionalArguments: '--scan ./ --disableYarnAudit --disableNodeAudit -n', odcInstallation: 'DP-Check'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage ("Trivy File Scan") {
steps {
sh "trivy fs . > trivy.txt"
}
}
stage ("Build Docker Image") {
steps {
sh "docker build -t zomato ."
}
}
stage ("Tag & Push to DockerHub") {
steps {
script {
withDockerRegistry(credentialsId: 'docker') {
sh "docker tag zomato kastrov/zomato:latest "
sh "docker push kastrov/zomato:latest "
}
}
}
}
stage('Docker Scout Image') {
steps {
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){
sh 'docker-scout quickview kastrov/zomato:latest'
sh 'docker-scout cves kastrov/zomato:latest'
sh 'docker-scout recommendations kastrov/zomato:latest'
}
}
}
}
stage ("Deploy to Container") {
steps {
sh 'docker run -d --name zomato -p 3000:3000 kastrov/zomato:latest'
}
}
}
post {
always {
emailext attachLog: true,
subject: "'${currentBuild.result}'",
body: """
<html>
<body>
<div style="background-color: #FFA07A; padding: 10px; margin-bottom: 10px;">
<p style="color: white; font-weight: bold;">Project: ${env.JOB_NAME}</p>
</div>
<div style="background-color: #90EE90; padding: 10px; margin-bottom: 10px;">
<p style="color: white; font-weight: bold;">Build Number: ${env.BUILD_NUMBER}</p>
</div>
<div style="background-color: #87CEEB; padding: 10px; margin-bottom: 10px;">
<p style="color: white; font-weight: bold;">URL: ${env.BUILD_URL}</p>
</div>
</body>
</html>
""",
to: '[email protected]',
mimeType: 'text/html',
attachmentsPattern: 'trivy.txt'
}
}
}