forked from MOHITH-2002/Qr-Tickets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins-pipeline
106 lines (84 loc) · 3.35 KB
/
jenkins-pipeline
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
pipeline {
agent any
tools{
nodejs 'node22'
}
environment {
SCANNER_HOME= tool 'sonar-scanner'
}
stages{
stage('git checkout') {
steps {
git branch: 'main', url: 'https://github.com/MOHITH-2002/Qr-Tickets.git'
}
}
stage('installing dependencies') {
steps {
sh "npm install"
}
}
stage('Trivy FileSystem Scan') {
steps {
sh "trivy fs --format table -o fs-report.html ."
}
}
stage('sonnar-Qube scan') {
steps {
withSonarQubeEnv('sonar-qube-scanner') {
sh " $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectKey=Auth -Dsonar.projectName=Auth"
}
}
}
stage('docker Build and tag') {
steps {
script {
// This step should not normally be used in your script. Consult the inline help for details.
withDockerRegistry(credentialsId: 'docker-hub-creditentials', toolName: 'docker') {
sh "docker build -t mohith9353/qr-ticket:latest ."
}
}
}
}
stage('Trivy image Scan for docker repo ') {
steps {
sh "trivy image --format table -o fs-report.html mohith9353/qr-tickets:latest"
}
}
stage('docker image push') {
steps {
script {
// This step should not normally be used in your script. Consult the inline help for details.
withDockerRegistry(credentialsId: 'docker-hub-creditentials', toolName: 'docker') {
sh "docker push mohith9353/qr-ticket:latest"
}
}
}
}
stage('deploy to eks ') {
steps {
withKubeCredentials(kubectlCredentials: [[caCertificate: '', clusterName: 'auth-devops', contextName: '', credentialsId: 'k8-service', namespace: 'auth-devops', serverUrl: 'https://8E7960A2B61274F37CF1D1FED98B76FB.gr7.ap-south-1.eks.amazonaws.com']]) {
sh "kubectl apply -f dss.yml"
sleep 60
}
}
}
stage('verifying the deployment') {
steps {
withKubeCredentials(kubectlCredentials: [[caCertificate: '', clusterName: 'auth-devops', contextName: '', credentialsId: 'k8-service', namespace: 'auth-devops', serverUrl: 'https://8E7960A2B61274F37CF1D1FED98B76FB.gr7.ap-south-1.eks.amazonaws.com']]) {
sh "kubectl get pods -n auth-devops"
sh "kubectl get svc -n auth-devops"
}
}
}
// stage('docker run') {
// steps {
// script {
// // This step should not normally be used in your script. Consult the inline help for details.
// withDockerRegistry(credentialsId: 'docker-hub-creditentials', toolName: 'docker') {
// sh "docker run -d -p 3000:3000 mohith9353/qr-ticket:latest"
// }
// }
// }
// }
}
}