forked from open-hand/agile-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
165 lines (155 loc) · 4.96 KB
/
.gitlab-ci.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
image: registry.cn-shanghai.aliyuncs.com/c7n/cibase:0.10.1
stages:
- build
- release
build front:
stage: build
script:
- npm install --registry ${NPM_REPO} --sass-binary-site=http://npm.taobao.org/mirrors/node-sass
- chmod -R 755 node_modules
- npm run compile
- echo "//${NPM_REGISTRY}:_authToken=${NPM_TOKEN}">.npmrc
- npm publish --registry ${NPM_PUBLISH_REGISTRY}
- curl -sX POST -F token=${FRONT_REPOSITORY_TOKEN} -F ref=${REF_NAME} https://code.choerodon.com.cn/api/v4/projects/7909/trigger/pipeline
except:
changes:
- pom.xml
- src/**/*
- docker/**/*
- chart/**/*
- init-mysql-database.sh
- .circleci/**/*
- .gitignore
- .github/**/*
- .gitlab-ci.yml
- "*.md"
variables:
- $CI_COMMIT_MESSAGE =~ /combine/
tag front:
stage: build
script:
- npm install --registry ${NPM_REPO} --sass-binary-site=http://npm.taobao.org/mirrors/node-sass
- chmod -R 755 node_modules
- npm run compile
- echo "//${NPM_REGISTRY}:_authToken=${NPM_TOKEN}">.npmrc
- npm publish --registry ${NPM_PUBLISH_REGISTRY}
only:
- tags
build backend:
stage: build
script:
- update_pom_version
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent test -Dmaven.test.failure.ignore=true -DskipTests=true -U
- >-
mvn --batch-mode verify sonar:sonar
-Dsonar.host.url=$SONAR_URL
-Dsonar.login=$SONAR_LOGIN
-Dsonar.gitlab.project_id=$CI_PROJECT_PATH
-Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
-Dsonar.analysis.serviceGroup=$GROUP_NAME
-Dsonar.analysis.commitId=$CI_COMMIT_SHA
-Dsonar.projectKey=${GROUP_NAME}:${PROJECT_NAME}
- mvn package spring-boot:repackage
- mv target/app.jar $PWD/docker
- kaniko -c $PWD/docker -f $PWD/docker/Dockerfile -d ${DOCKER_REGISTRY}/${GROUP_NAME}/${PROJECT_NAME}:${CI_COMMIT_TAG}
except:
changes:
- .editorconfig
- .eslintrc.json
- .stylelintrc.json
- gulpfile.js
- package.json
- react/**/*
- .gitignore
- .github/**/*
- .gitlab-ci.yml
- "*.md"
variables:
- $CI_COMMIT_MESSAGE =~ /combine/
tag backend:
stage: build
script:
- update_pom_version
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent test -Dmaven.test.failure.ignore=true -DskipTests=true -U
- >-
mvn --batch-mode verify sonar:sonar
-Dsonar.host.url=$SONAR_URL
-Dsonar.login=$SONAR_LOGIN
-Dsonar.gitlab.project_id=$CI_PROJECT_PATH
-Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
-Dsonar.analysis.serviceGroup=$GROUP_NAME
-Dsonar.analysis.commitId=$CI_COMMIT_SHA
-Dsonar.projectKey=${GROUP_NAME}:${PROJECT_NAME}
- mvn package spring-boot:repackage
- mv target/app.jar $PWD/docker
- kaniko -c $PWD/docker -f $PWD/docker/Dockerfile -d ${DOCKER_REGISTRY}/${GROUP_NAME}/${PROJECT_NAME}:${CI_COMMIT_TAG}
only:
- tags
build combine:
stage: build
script:
- update_pom_version
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent test -Dmaven.test.failure.ignore=true -DskipTests=true -U
- >-
mvn --batch-mode verify sonar:sonar
-Dsonar.host.url=$SONAR_URL
-Dsonar.login=$SONAR_LOGIN
-Dsonar.gitlab.project_id=$CI_PROJECT_PATH
-Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
-Dsonar.analysis.serviceGroup=$GROUP_NAME
-Dsonar.analysis.commitId=$CI_COMMIT_SHA
-Dsonar.projectKey=${GROUP_NAME}:${PROJECT_NAME}
- mvn package spring-boot:repackage
- mv target/app.jar docker
- npm install --registry ${NPM_REPO} --sass-binary-site=http://npm.taobao.org/mirrors/node-sass
- chmod -R 755 node_modules
- npm run dist
- mv src/main/resources/lib/dist docker
- cp /usr/bin/kaniko $PWD/docker
- kaniko -c $PWD/docker -f $PWD/docker/Dockerfile-combine -d ${DOCKER_REGISTRY}/${GROUP_NAME}/${PROJECT_NAME}:${CI_COMMIT_TAG}
only:
variables:
- $CI_COMMIT_MESSAGE =~ /combine/
release backend:
stage: release
script:
- chart_build
except:
changes:
- .editorconfig
- .eslintrc.json
- .stylelintrc.json
- gulpfile.js
- package.json
- react/**/*
- .gitignore
- .github/**/*
- .gitlab-ci.yml
- "*.md"
variables:
- $CI_COMMIT_MESSAGE =~ /combine/
release combine:
stage: release
script:
- chart_build
only:
variables:
- $CI_COMMIT_MESSAGE =~ /combine/
tag release:
stage: release
script:
- chart_build
only:
- tags
.auto_devops: &auto_devops |
http_status_code=`curl -o .auto_devops.sh -s -m 10 --connect-timeout 10 -w %{http_code} "${CHOERODON_URL}/devops/ci?token=${Token}&type=microservice"`
if [ "$http_status_code" != "200" ]; then
cat .auto_devops.sh
exit 1
fi
source .auto_devops.sh
before_script:
- *auto_devops