-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
374 lines (319 loc) · 14.7 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
pipeline {
agent any
environment {
// gitlab
gitUrl = "192.168.1.150:10081/superobject/super-object.git"
gitCred = "Rbxxb7pBtyw6D_KqbNWa"
gitBranch = "${params.GitBranch}"
version = "${params.Version}"
releaseOption = "${params.ReleaseOption}"
versionFeature = "${params.VersionFeature}"
publisher = "${params.Publisher}"
sendTo = "${params.SendTo}"
prev_version = "default"
dockerRegistry = "192.168.9.12:5000"
publishUrl = "http://192.168.9.12:8081/repository/maven-releases"
repoUser = "root"
repoPassword = "tmax@23"
}
stages {
// stage('Git Clone') {
// steps {
// sh "sudo chown -R jenkins ."
// sh 'ls -al'
// sh 'rm -rf *'
// sh 'rm -rf .g*'
// sh 'git init'
// script {
// echo "${env.WORKSPACE}"
// if ("${gitUrl.tokenize('/')[0]}" == 'github.com') {
// credId = 'dohyun_github'
// } else {
// credId = 'gitlab_token'
// }
// git([branch: "${gitBranch}", credentialsId:"${credId}", url: "http://${gitCred}@${gitUrl}"])
// }
// }
// }
stage('Git Clone') {
steps {
sh "sudo chown -R jenkins ."
sh 'ls -al'
sh 'rm -rf *'
sh 'rm -rf .g*'
sh 'git init'
script {
echo "${env.WORKSPACE}"
if ("${gitUrl.tokenize('/')[0]}" == 'github.com') {
credId = 'dohyun_github'
} else {
credId = 'gitlab_token'
}
git([branch: "${gitBranch}", credentialsId:"${credId}", url: "http://${gitCred}@${gitUrl}"])
}
}
}
stage('Git Tagging') {
steps {
sh 'git fetch --all'
script {
if ("${prev_version}" == "default") {
prev_version = sh(script:"sudo git describe --tags --abbrev=0", returnStdout: true).tokenize('-')[1].replace("v","")
echo "${prev_version}"
}
if ("${gitBranch}" == 'master') {
echo "****************************************This is master!*********************************"
sh "git checkout -b release-${version}"
gitBranch = "release-${version}"
} else {
echo "****************************************${gitBranch}!***********************************"
}
commitId = sh(returnStdout: true, script: "git log | head -1 | cut -b 7-15")
commitId = commitId.substring(1)
tagName = "release-v${version}"
sh "git tag -a ${tagName} -m 'Version ${version} update'"
}
}
}
stage('Build Jar') {
steps {
echo "${version}"
sh 'chmod +x ./gradlew'
sh "./gradlew clean build jenkins -PbuildVersion=${version} -PcommitId=${commitId}"
}
}
stage('Upload Jar') {
steps {
sh "./gradlew publish -PbuildVersion=${version} -PpublishUrl=${publishUrl} -PrepoUser=${repoUser} -PrepoPassword=${repoPassword}"
}
}
stage('Build Package & Upload to ftp server') {
steps {
script {
sh "sudo sh ./scripts/packaging.sh"
if (releaseOption == 'Full release' || releaseOption == 'Fix to Full release') {
sh "sudo sh ./scripts/uploading.sh"
}
}
}
}
stage ('Build and Upload Docker Image') {
steps {
script {
def dockerImage = docker.build("${dockerRegistry}/super-app-server:${version}", "--build-arg version=${version} --cache-from=${dockerRegistry}/super-app-server:latest .")
sh "docker login hyperregistry.tmaxcloud.org -u admin -p admin"
sh "docker tag ${dockerRegistry}/super-app-server:${version} hyperregistry.tmaxcloud.org/super-app-server/super-app-server:${version}"
sh "docker push hyperregistry.tmaxcloud.org/super-app-server/super-app-server:${version}"
sh "docker rmi ${dockerRegistry}/super-app-server:${version}"
}
}
}
stage('Edit ChangeLog') {
steps {
script {
def gitDomain = "${gitUrl}".tokenize('/')[0]
def changelogString = gitChangelog returnType: 'STRING',
from: [type: 'REF', value: "tags/release-v${prev_version}"],
to: [type: 'REF', value: "tags/release-v${version}"],
template:
"""
{{#tags}}
# {{name}}
{{#issues}}
{{#ifContainsType commits type='feat'}}
## Features
{{#commits}}
{{#ifCommitType . type='feat'}}
**{{#eachCommitScope .}} {{.}} {{/eachCommitScope}}{{{commitDescription .}}}** ([{{hash}}](http://${gitDomain}/{{ownerName}}/{{repoName}}/commit/{{hash}})) *{{authorName}} {{commitTime}}*
{{#messageBodyItems}}
*{{.}}*
{{/messageBodyItems}}
{{/ifCommitType}}
{{/commits}}
{{/ifContainsType}}
{{#ifContainsType commits type='mod'}}
## Refactor
{{#commits}}
{{#ifCommitType . type='mod'}}
**{{#eachCommitScope .}} {{.}} {{/eachCommitScope}}{{{commitDescription .}}}** ([{{hash}}](http://${gitDomain}/{{ownerName}}/{{repoName}}/commit/{{hash}})) *{{authorName}} {{commitTime}}*
{{#messageBodyItems}}
*{{.}}*
{{/messageBodyItems}}
{{/ifCommitType}}
{{/commits}}
{{/ifContainsType}}
{{#ifContainsType commits type='fix'}}
## Bug Fixes
{{#commits}}
{{#ifCommitType . type='fix'}}
**{{#eachCommitScope .}} {{.}} {{/eachCommitScope}}{{{commitDescription .}}}** ([{{hash}}](http://${gitDomain}/{{ownerName}}/{{repoName}}/commit/{{hash}})) *{{authorName}} {{commitTime}}*
{{#messageBodyItems}}
*{{.}}*
{{/messageBodyItems}}
{{/ifCommitType}}
{{/commits}}
{{/ifContainsType}}
{{#ifContainsType commits type='etc'}}
## OTHERS
{{#commits}}
{{#ifCommitType . type='etc'}}
**{{#eachCommitScope .}} {{.}} {{/eachCommitScope}}{{{commitDescription .}}}** ([{{hash}}](http://${gitDomain}/{{ownerName}}/{{repoName}}/commit/{{hash}})) *{{authorName}} {{commitTime}}*
{{#messageBodyItems}}
*{{.}}*
{{/messageBodyItems}}
{{/ifCommitType}}
{{/commits}}
{{/ifContainsType}}
{{/issues}}
{{/tags}}
"""
writeFile file: "tmp/CHANGELOG_new", text: changelogString
currentBuild.description = changelogString
sh "mv CHANGELOG.md tmp/tmpfile"
sh "cat tmp/CHANGELOG_new > CHANGELOG.md"
sh "cat tmp/tmpfile >> CHANGELOG.md"
sh "ls -al"
}
}
}
stage('Send Email') {
steps {
script {
def publisherEmails = [
'김도현': '[email protected]',
'송민재': '[email protected]',
'노정완': '[email protected]',
'이성민': '[email protected]',
'최성훈': '[email protected]',
'김현식': '[email protected]',
'유현수': '[email protected]',
'이재훈': '[email protected]'
]
def sendToEmails = [
'CK RnD, QA': '[email protected]; [email protected];',
'CK1, QA': '[email protected]; [email protected];',
'CK1-2, QA': '[email protected]; [email protected];',
'Publisher only': '[email protected];'
]
def fromEmail = publisherEmails[publisher]
def toEmail = sendToEmails[sendTo]
if (releaseOption == 'Full release' || releaseOption == 'Fix release') {
emailext (
attachmentsPattern: 'CHANGELOG.md',
subject: "[super-app-server] Release Notes - super-app-server:${version}",
body:
"""
안녕하세요. ck1-2팀 ${publisher}입니다.
금주 배포된 super-app-server:${version} release 버전에 대한 안내 및 가이드 메일 드립니다.
${version}의 개선 및 추가된 사항은 아래 Super-App-Server Release Note 링크를 참고 부탁드립니다.
https://flying-balmoral-4aa.notion.site/Super-App-Server-Release-Note-9cb55fc059ef4559988dda2c069e1054
===
Super-App-Server-${version} 버전에서는 다음과 같은 기능이 추가되었습니다.
${versionFeature}
자세한 예시 코드 및 가이드를 Wiki에 업로드 할 예정이오니
super-object Wiki를 참고해 주시면 감사하겠습니다.
===
※ SuperApp 서비스 예제 프로젝트:
http://192.168.1.150:10081/superobject/super-app-service-example
해당 프로젝트를 참조하여 AbstractServiceObject 를 상속받아 슈퍼앱 서비스를 구현하고,
super-app-runtime.jar 런타임을 실행시키면 테스트가 가능합니다.
구체적인 설치 및 서비스 개발, 그리고 테스트 가이드에 대한 내용은 해당 WIKI 가이드 참고 부탁드립니다.
http://192.168.1.150:10081/superobject/super-object/wikis/home
SuperApp Server 관련된 문의사항 있으실 경우 메일 혹은 WAPL TF를 통해 문의해주시면 바로 대응하도록 하겠습니다.
감사합니다.
- ${publisher} 드림.
※ SuperApp Server Runtime :
http://192.168.9.12/binary/super-app-runtime/super-app-runtime-${version}
※ SuperApp Server Maven Repository :
http://192.168.9.12:8081/#browse/browse:maven-releases:com%2Ftmax%2Fsuper-app-server%2F0.0.5%2Fsuper-app-server-${version}.jar
※ SuperApp Server Project :
http://192.168.1.150:10081/superobject/super-object/tree/release-${version}
※ OSS Super App Server :
http://192.168.1.150:10081/superobject/super-object/-/wikis/OSS-SAS
※ SuperApp Server Container Image :
hyperregistry.tmaxcloud.org/super-app-server/super-app-server:${version}
※ gitlab.ck:10081 접속 방법 :
Default DNS 192.168.1.150 로 설정
""",
to: toEmail,
// to: "[email protected]",
from: fromEmail
)
} else if (releaseOption == 'Fix to Full release') {
emailext (
attachmentsPattern: 'CHANGELOG.md',
subject: "[super-app-server] Release Notes - super-app-server:${version}",
body:
"""
안녕하세요. ck1-2팀 ${publisher}입니다.
금주 배포된 super-app-server:${version} release 버전에 대한 안내 및 가이드 메일 드립니다.
${version}의 개선 및 추가된 사항은 아래 Super-App-Server Release Note 링크를 참고 부탁드립니다.
https://flying-balmoral-4aa.notion.site/Super-App-Server-Release-Note-9cb55fc059ef4559988dda2c069e1054
===
Super-App-Server-${version} 버전은 ${gitBranch}형상에서 ${prev_version}까지의 픽스 수정사항들을 통합한 정식 버전 배포입니다.
===
※ SuperApp 서비스 예제 프로젝트:
http://192.168.1.150:10081/superobject/super-app-service-example
해당 프로젝트를 참조하여 AbstractServiceObject 를 상속받아 슈퍼앱 서비스를 구현하고,
super-app-runtime.jar 런타임을 실행시키면 테스트가 가능합니다.
구체적인 설치 및 서비스 개발, 그리고 테스트 가이드에 대한 내용은 해당 WIKI 가이드 참고 부탁드립니다.
http://192.168.1.150:10081/superobject/super-object/wikis/home
SuperApp Server 관련된 문의사항 있으실 경우 메일 혹은 WAPL TF를 통해 문의해주시면 바로 대응하도록 하겠습니다.
감사합니다.
- ${publisher} 드림.
※ SuperApp Server Runtime :
http://192.168.9.12/binary/super-app-runtime/super-app-runtime-${version}
※ SuperApp Server Maven Repository :
http://192.168.9.12:8081/#browse/browse:maven-releases:com%2Ftmax%2Fsuper-app-server%2F0.0.5%2Fsuper-app-server-${version}.jar
※ SuperApp Server Project :
http://192.168.1.150:10081/superobject/super-object/tree/release-${version}
※ OSS Super App Server :
http://192.168.1.150:10081/superobject/super-object/-/wikis/OSS-SAS
※ SuperApp Server Container Image :
hyperregistry.tmaxcloud.org/super-app-server/super-app-server:${version}
※ gitlab.ck:10081 접속 방법 :
Default DNS 192.168.1.150 로 설정
""",
to: toEmail,
// to: "[email protected]",
from: fromEmail
)
}
}
}
}
stage('Git Push') {
steps {
echo "pushing..."
script {
commitMsg = "Release commit - version ${version}"
sh "git add -A"
sh "git commit -m \"${commitMsg}\" || true"
// re-tag to apply Release-note
tagName = "release-v${version}"
sh "git tag -d ${tagName}"
sh "git tag -a ${tagName} -m 'Version ${version} update'"
sh "git remote rm origin"
sh "git remote add origin http://dohyun_kim5:ehgus0303!@${gitUrl}"
sh "git remote -v"
sh "git push origin refs/tags/${tagName}:refs/tags/${tagName}"
sh "git push origin refs/heads/${gitBranch}:refs/heads/${gitBranch}"
}
}
}
stage('Cleaning...') {
steps {
echo "All work Done. Cleaning..."
echo "Check the @tmp directory for confirm."
script {
sh "sudo echo ${WORKSPACE}"
sh "sudo rsync -a ${env.WORKSPACE} ${env.WORKSPACE}@tmp"
sh "sudo echo ${WORKSPACE}"
sh "cd ${WORKSPACE}"
sh "sudo chown -R jenkins ."
}
deleteDir()
}
}
}
}