-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
192 lines (175 loc) · 4.5 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
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
image: maven:latest
stages:
# - cache
- test-spring
- test-android
- test-site
- build-spring
- deploy-spring
- deploy-site
variables:
MAVEN_CLI_OPTS: "--batch-mode"
SPRING_PROFILES_ACTIVE: gitlab-ci
OUTPUT_JAR_PROD: "cyio-backend-prod"
OUTPUT_JAR_DEV: "cyio-backend-dev"
NPM_PATH: "/usr/local/bin/npm"
cache:
paths:
- backend/target/
- react/build/
# Change Gitlab-Runner Home directory file permissions and remove node_modlues if there
default:
before_script:
- sudo chmod 777 /home/gitlab-runner/ -R
- sudo rm /home/gitlab-runner/builds/SDjQd5kx/0/cs309/fall2019/nv_4/react/node_modules/ -rf
after_script:
- sudo chmod 777 /home/gitlab-runner/ -R
- sudo rm /home/gitlab-runner/builds/SDjQd5kx/0/cs309/fall2019/nv_4/react/node_modules/ -rf
# Build Springboot Backend
Build Maven Backend:
stage: build-spring
script:
- cd backend
- mvn $MAVEN_CLI_OPTS compile
# Test Springboot Backend For Production Environment
Test Springboot Prod:
stage: test-spring
allow_failure: false
script:
- cd backend
- mvn $MAVEN_CLI_OPTS test
only:
- master
# Test Springboot Backend For Development Environment
Test Springboot Dev:
stage: test-android
allow_failure: true
script:
- cd backend
- mvn $MAVEN_CLI_OPTS test
only:
- branches
except:
- master
# Test Website Frontend For Development Environment
Test Site Dev:
stage: test-site
allow_failure: true
script:
- cd react
- $NPM_PATH install
# - sudo chmod -R +xwr .
- $NPM_PATH test
only:
- branches
except:
- master
# Test Website Frontend For Production Environment
Test Site Prod:
stage: test-site
allow_failure: true
script:
- cd react
- $NPM_PATH install
# - sudo chmod -R +xwr .
- $NPM_PATH test
only:
- master
# Test Android Application for Development Environment
Test Android Dev:
stage: test-android
allow_failure: true
script:
- cd Android/PlaceHolder
- sudo chmod -R +xwr .
- ./gradlew test --stacktrace
# - sudo ./gradlew -Pci --console=plane :app:testDebug
only:
- branches
except:
- master
# Test Android Application for Production Environment
Test Android Prod:
stage: test-spring
allow_failure: true
script:
- cd Android/PlaceHolder
- sudo chmod -R +xwr .
- ./gradlew test --stacktrace
# - sudo ./gradlew -Pci --console=plane :app:testDebug
only:
- master
# Deploy Springboot Backend to Production Environment
Deploy Springboot to Prod Environment:
stage: deploy-spring
allow_failure: true
environment:
name: prod/$CI_COMMIT_REF_SLUG
script:
- echo "Deploying Production Backend Server"
- cd backend
- mvn $MAVEN_CLI_OPTS clean package
- sudo systemctl stop cyio-prod
- sudo mv `ls target/*.jar | head -n 1` /home/server-files/prod/$OUTPUT_JAR_PROD.jar
- sudo systemctl start cyio-prod
artifacts:
paths:
- backend/target/*.jar
only:
- master
# Deploy Springboot Backend to Development Environment
Deploy SpringBoot to Dev Environment:
stage: deploy-spring
when: manual
script:
- echo "Deploying Development Backend Server"
- cd backend
- mvn $MAVEN_CLI_OPTS -Djar.finalName=$OUTPUT_JAR_DEV clean package
- sudo systemctl stop cyio-dev
- sudo mv `ls target/*.jar | head -n 1` /home/server-files/dev/$OUTPUT_JAR_DEV.jar
- sudo systemctl start cyio-dev
environment:
name: review/$CI_COMMIT_REF_NAME
artifacts:
paths:
- backend/target/*.jar
only:
- branches
except:
- master
# Deploy Site to Production Environment:
Deploy React Prod Site:
stage: deploy-site
allow_failure: true
script:
# - sudo docker cp gitlab-runner:/builds/cs309/fall2019/nv_4/frontend/ /var/www/html/
- cd react/
- $NPM_PATH install
# - sudo chmod -R +xwr .
- CI=false $NPM_PATH run build-auto
- sudo rm -rf /var/www/prod-site/*
- sudo mv -f build/* /var/www/prod-site/
artifacts:
paths:
- react/build/
only:
- master
# Deploy Site to Development Environment:
Deploy React Dev Site:
stage: deploy-site
when: manual
script:
# - sudo docker cp gitlab-runner:/builds/cs309/fall2019/nv_4/frontend/ /var/www/html/
- cd react/
- $NPM_PATH install
# - sudo chmod -R +xwr .
- CI=false $NPM_PATH run build-auto
- sudo rm -rf /var/www/dev-site/*
- sudo mv -f build/* /var/www/dev-site/
artifacts:
paths:
- react/build/
only:
- branches
except:
- master