This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
shell.yml
713 lines (699 loc) · 31.1 KB
/
shell.yml
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
#
# 使用 shell 执行器 打包
shell-package:
stage: shell-package
script:
# 只能导入一次,否则会报错(开发者自己导入,或者不使用 gpg)
# - GPG_FILE=`find / -name xuxiaowei_0x97A36125_SECRET`
# - echo $GPG_FILE
# - gpg --import $GPG_FILE
- git --version
- echo 常量网址:https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
- echo 常量网址(极狐GitLab中文文档):https://docs.gitlab.cn/jh/ci/variables/predefined_variables.html
- echo 当前分支:$CI_COMMIT_BRANCH
- echo 主分支:$CI_DEFAULT_BRANCH
- echo 项目路径:$CI_PROJECT_DIR
# 在 Shell 执行器中,如果手动导入 gpg,可使用参数 -Pgpg
# 在 Shell 执行器中,如果不指定 settings.xml,可使用系统默认
- mvn clean -e -U package source:jar javadoc:jar install -DskipTests -s settings-private.xml && PACKAGE_FLAG=1
- if [ "$PACKAGE_FLAG" == "1" ]; then echo '打包完成'; else echo '打包失败' && xxxx; fi
cache:
key: "${CI_JOB_NAME}"
paths:
- .m2/repository
- passport-ui/node/
- passport-ui/node_modules/
- ui/node/
- ui/node_modules/
artifacts:
name: package
paths:
- target/*.jar
- target/*.asc
- target/*.pom
- "*/target/*.jar"
- "*/target/*.asc"
- "*/target/*.pom"
- "*/*/target/*.jar"
- "*/*/target/*.asc"
- "*/*/target/*.pom"
- ui/dist
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布网关服务
shell-service-gateway:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- MODULE='gateway'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布监控(管理)服务
shell-service-admin-server:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- MODULE='admin-server'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布登录服务
shell-service-passport:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- MODULE='passport'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布MySQL二进制订阅服务
shell-service-canal:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- cd resource-services-parent
- pwd
- MODULE='canal'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布用户服务
shell-service-user:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- cd resource-services-parent
- pwd
- MODULE='user'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布主数据服务
shell-service-master-data:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- cd resource-services-parent
- pwd
- MODULE='master-data'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-master-data.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布WebSocket服务
shell-service-websocket:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- cd resource-services-parent
- pwd
- MODULE='websocket'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布WebService服务
shell-service-webservice:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- cd resource-services-parent
- pwd
- MODULE='webservice'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布微信小程序服务
shell-service-wechat-miniprogram:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- cd resource-services-parent
- pwd
- MODULE='wechat-miniprogram'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布微信公众号服务
shell-service-wechat-offiaccount:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- cd resource-services-parent
- pwd
- MODULE='wechat-offiaccount'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布文件服务
shell-service-file:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- cd resource-services-parent
- pwd
- MODULE='file'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布 XXL Job
shell-service-xxl-job-admin:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- JAR_PATH=/home/gitlab-runner/jar/$CI_COMMIT_BRANCH
- echo JAR_PATH:$JAR_PATH
- if [ ! -f $JAR_PATH ]; then sudo mkdir $JAR_PATH -p && echo 创建发布文件夹完成; fi
- MODULE='xxl-job-admin'
- echo MODULE:$MODULE
- ARTIFACT_ID=`mvn -e -U help:evaluate -pl $MODULE -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn help:evaluate -pl $MODULE -Dexpression=project.version -q -DforceStdout`
- PACKAGING=`mvn help:evaluate -pl $MODULE -Dexpression=project.packaging -q -DforceStdout`
- APP_NAME=$ARTIFACT_ID-$VERSION.$PACKAGING
- echo APP_NAME:$APP_NAME
- cp $MODULE/target/$APP_NAME $JAR_PATH/$APP_NAME && echo 复制新jar包完成
- SERVICE=/usr/lib/systemd/system/xxw-$MODULE.service
- echo SERVICE:$SERVICE
- JAVA_HOME=/software/dragonwell-17.0.7.0.7+7-GA
- echo JAVA_HOME:$JAVA_HOME
- echo "" > $SERVICE
- echo "[Unit]" >> $SERVICE
- echo "Description=$MODULE" >> $SERVICE
- echo "After=syslog.target" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Service]" >> $SERVICE
- echo "EnvironmentFile=/etc/profile" >> $SERVICE
- echo "ExecStart=$JAVA_HOME/bin/java -jar $JAR_PATH/$APP_NAME --spring.profiles.active=prod" >> $SERVICE
- echo "" >> $SERVICE
- echo "[Install]" >> $SERVICE
- echo "WantedBy=multi-user.target" >> $SERVICE
- echo "" >> $SERVICE
- echo 创建新启动脚本完成
- sudo systemctl enable xxw-$MODULE.service && echo 设置开机启动完成
- sudo systemctl daemon-reload
- sudo systemctl restart xxw-$MODULE.service && echo 重启项目完成
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
- MODULE_STATUS=0
- sleep 30 && echo 增加延时
- sudo systemctl status xxw-$MODULE.service && MODULE_STATUS=1
- if [ "$MODULE_STATUS" == "1" ]; then echo '延时查看项目状态成功'; else echo '查看项目状态失败' && xxxx; fi
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell
#
# shell 发布UI服务
shell-service-ui:
stage: shell-service
needs:
- job: shell-package
artifacts: true
script:
- MODULE='ui'
- echo MODULE:$MODULE
- RELEASE_PATH=/home/gitlab-runner/node/$MODULE
- if [ ! -f $RELEASE_PATH ]; then sudo mkdir $RELEASE_PATH -p && echo 创建文件夹完成; fi
- echo RELEASE_PATH:$RELEASE_PATH
- if [ ! -f $RELEASE_PATH ]; then sudo mkdir $RELEASE_PATH -p && echo 创建发布文件夹完成; fi
# 此处每次发包仅仅是将新打包完成的文件,复制到需要发布的文件夹(除了 index.html、favicon.ico 等文件外,其他 CSS/JS 文件名不同,不会覆盖。随着发布次数变多,发布文件夹可能会非常大)
# 历史发布的文件没有删除
# 用户刷新页面后使用最新的前端(index.html等)
# 如果发包后需要用户立即使用最新前端,需要将历史文件删除后再进行复制(发布后,用户不刷新,对于没有之前没有点击的页面可能会出现404,刷新页面后即可)
- cp -r ./$MODULE/dist/* $RELEASE_PATH && echo 复制新文件夹完成
rules:
# 仅在 shell 分支中执行
- if: $CI_COMMIT_BRANCH == "shell"
tags:
# 仅在 tags 名称为 shell 的执行器上执行
- plugin-shell