forked from devops0014/python-code-library-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkinsscript
More file actions
165 lines (165 loc) · 5.09 KB
/
Copy pathjenkinsscript
File metadata and controls
165 lines (165 loc) · 5.09 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
pipeline{
agent {
node {
label 'oneplus'
}
}
environment {
scannerHome = tool 'mysonar'
}
stages {
stage("Code"){
steps {
git 'https://github.com/Pavankumar49280/python-code-library-app.git'
}
}
stage("CQA"){
steps{
withSonarQubeEnv('mysonar') {
sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=myproject"
}
}
}
stage("Qualitygate") {
steps {
waitForQualityGate abortPipeline: false, credentialsId: 'sonar_cred'
}
}
stage("Build"){
steps {
sh '''
docker build -t db database
docker build -t authimage auth
docker build -t bookimage book
docker build -t borrowimage borrow
docker build -t frontimage .
'''
}
}
stage("Scan"){
steps {
sh '''
trivy image db
trivy image authimage
trivy image bookimage
trivy image borrowimage
trivy image frontimage
'''
}
}
stage("Registry") {
steps {
script {
withDockerRegistry(credentialsId: 'docker_cred') {
sh '''
docker tag db kumar49/secondproject:db
docker tag authimage kumar49/secondproject:authimage
docker tag bookimage kumar49/secondproject:bookimage
docker tag borrowimage kumar49/secondproject:borrowimage
docker tag frontimage kumar49/secondproject:frontimage
docker push kumar49/secondproject:db
docker push kumar49/secondproject:authimage
docker push kumar49/secondproject:bookimage
docker push kumar49/secondproject:borrowimage
docker push kumar49/secondproject:frontimage
'''
}
}
}
}
stage ("Deploy"){
steps {
sh "docker stack deploy pavan --compose-file=compose.yml"
}
}
}
post {
always {
mail to: '[email protected]',
subject: "SUCCESS: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
body: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} \n build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}"
}
}
}pipeline{
agent {
node {
label 'oneplus'
}
}
environment {
scannerHome = tool 'mysonar'
}
stages {
stage("Code"){
steps {
git 'https://github.com/Pavankumar49280/python-code-library-app.git'
}
}
stage("CQA"){
steps{
withSonarQubeEnv('mysonar') {
sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=myproject"
}
}
}
stage("Qualitygate") {
steps {
waitForQualityGate abortPipeline: false, credentialsId: 'sonar_cred'
}
}
stage("Build"){
steps {
sh '''
docker build -t db database
docker build -t authimage auth
docker build -t bookimage book
docker build -t borrowimage borrow
docker build -t frontimage .
'''
}
}
stage("Scan"){
steps {
sh '''
trivy image db
trivy image authimage
trivy image bookimage
trivy image borrowimage
trivy image frontimage
'''
}
}
stage("Registry") {
steps {
script {
withDockerRegistry(credentialsId: 'docker_cred') {
sh '''
docker tag db kumar49/secondproject:db
docker tag authimage kumar49/secondproject:authimage
docker tag bookimage kumar49/secondproject:bookimage
docker tag borrowimage kumar49/secondproject:borrowimage
docker tag frontimage kumar49/secondproject:frontimage
docker push kumar49/secondproject:db
docker push kumar49/secondproject:authimage
docker push kumar49/secondproject:bookimage
docker push kumar49/secondproject:borrowimage
docker push kumar49/secondproject:frontimage
'''
}
}
}
}
stage ("Deploy"){
steps {
sh "docker stack deploy pavan --compose-file=compose.yml"
}
}
}
post {
always {
mail to: '[email protected]',
subject: "SUCCESS: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
body: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} \n build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}"
}
}
}