-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsPipeline-Prod
92 lines (81 loc) · 2.47 KB
/
JenkinsPipeline-Prod
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
pipeline {
agent any
tools {
nodejs 'node21'
}
environment {
SCANNER_HOME = tool 'sonar-scanner'
}
stages {
stage('Git Checkout') {
steps {
git branch: 'main', url: 'https://github.com/vsingh55/3-tier-Architecture-Deployment-across-Multiple-Environments.git'
}
}
stage('Install Package Dependencies') {
steps {
dir('src') {
sh 'npm install'
}
}
}
stage('Unit Test') {
steps {
dir('src') {
sh 'npm test'
}
}
}
stage('Trivy FS Scan') {
steps {
dir('src') {
sh 'trivy fs --format table -o fs-report.html .'
}
}
}
stage('SonarQube') {
steps {
dir('src') {
withSonarQubeEnv("sonar") {
sh "\$SCANNER_HOME/bin/sonar-scanner -Dsonar.projectKey=Campground -Dsonar.projectName=Campground"
}
}
}
}
stage('Docker Build & Tag') {
steps {
script {
dir('src') {
withDockerRegistry(credentialsId: 'docker-crd', toolName: 'docker') {
sh "docker build -t vsingh55/campprod:latest ."
}
}
}
}
}
stage('Trivy Image Scan') {
steps {
sh 'trivy image --format table -o image-report.html vsingh55/campprod:latest'
}
}
stage('Docker Push Image') {
steps {
script {
withDockerRegistry(credentialsId: 'docker-crd', toolName: 'docker') {
sh "docker push vsingh55/campprod:latest"
}
}
}
}
stage('Deploy to AKS Cluster') {
steps {
dir('src') {
withCredentials([file(credentialsId: 'k8-secret', variable: 'KUBECONFIG')]) {
sh "kubectl apply -f Manifests/dss.yml -n webapps"
sh "kubectl apply -f Manifests/svc.yml -n webapps"
}
}
}
}
}
}