@@ -108,7 +108,7 @@ pipeline {
108
108
}
109
109
}
110
110
111
- stage(' Build projects' ) {
111
+ stage(' Build cer-graphql and search-proxy projects' ) {
112
112
stages {
113
113
stage(' Build search-proxy' ) {
114
114
when {
@@ -139,6 +139,98 @@ pipeline {
139
139
}
140
140
}
141
141
}
142
+ }
143
+ }
144
+
145
+ stage(' Run cer-graphql and search-proxy tests' ) {
146
+ stages {
147
+ stage(' Run cer-graphql tests' ) {
148
+ when {
149
+ anyOf {
150
+ changeset " **/cer-graphql/**/*.*"
151
+ equals expected : true , actual : params. FORCE_REDEPLOY_CG
152
+ }
153
+ }
154
+ steps {
155
+ script {
156
+ if (env. BRANCH_NAME != ' prod' ) { // tests rely on 2FAB so we do not test in prod
157
+ echo ' Testing cer-graphql project'
158
+ dir(' cer-graphql' ) {
159
+ sh " npm install"
160
+ sh " export stage=${ BRANCH_NAME} && npm run test -- --aws-profile=${ awsProfile} "
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
166
+ stage(' Run search-proxy tests' ) {
167
+ when {
168
+ anyOf {
169
+ changeset " **/hub-search-proxy/**/*.*"
170
+ equals expected : true , actual : params. FORCE_REDEPLOY_SP
171
+ }
172
+ }
173
+ steps {
174
+ script {
175
+ if (env. BRANCH_NAME != ' prod' ) {
176
+ echo " Testing hub-search-proxy project"
177
+ dir(' hub-search-proxy' ) {
178
+ sh " npm run test -- --aws-profile ${ awsProfile} --stage ${ env.BRANCH_NAME} "
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+
187
+ stage(' Deploy cer-graphql and search-proxy projects' ) {
188
+ parallel {
189
+ stage(' Deploy cer-graphql' ) {
190
+ when {
191
+ anyOf {
192
+ changeset " **/cer-graphql/**/*.*"
193
+ equals expected : true , actual : params. FORCE_REDEPLOY_CG
194
+ }
195
+ }
196
+ steps { // TODO: may need to modify commands once we have both dev & test in nonprod account
197
+ echo ' Deploying cer-graphql image to ECR on ' + BRANCH_NAME
198
+ echo " Logging in to ECR"
199
+ sh " (aws ecr get-login --no-include-email --region ${ awsRegion} --profile=${ awsProfile} ) | /bin/bash"
200
+
201
+ echo " Tagging built image with ECR tag"
202
+ sh " docker tag cer-graphql:latest ${ awsAccountId} .dkr.ecr.${ awsRegion} .amazonaws.com/research-hub/cer-graphql-${ BRANCH_NAME} :latest"
203
+
204
+ echo " Pushing built image to ECR"
205
+ sh " docker push ${ awsAccountId} .dkr.ecr.${ awsRegion} .amazonaws.com/research-hub/cer-graphql-${ BRANCH_NAME} :latest"
206
+
207
+ echo ' Deploying cer-graphql image from ECR to Fargate on ' + BRANCH_NAME
208
+ sh " aws ecs update-service --profile ${ awsProfile} --cluster cer-graphql-cluster-${ BRANCH_NAME} --service cer-graphql-service-${ BRANCH_NAME} --task-definition cer-graphql-${ BRANCH_NAME} --force-new-deployment --region ${ awsRegion} "
209
+ sh " aws ecs update-service --profile ${ awsProfile} --cluster cer-graphql-cluster-${ BRANCH_NAME} --service cer-graphql-preview-service-${ BRANCH_NAME} --task-definition cer-graphql-preview-${ BRANCH_NAME} --force-new-deployment --region ${ awsRegion} "
210
+ }
211
+ }
212
+ stage(' Deploy search-proxy' ) {
213
+ when {
214
+ anyOf {
215
+ changeset " **/hub-search-proxy/**/*.*"
216
+ equals expected : true , actual : params. FORCE_REDEPLOY_SP
217
+ }
218
+ }
219
+ steps {
220
+ echo " Deploying hub-search-proxy Lambda function to ${ BRANCH_NAME} "
221
+ script {
222
+ dir(" hub-search-proxy" ) {
223
+ sh " npm run deploy -- --aws-profile ${ awsProfile} --stage ${ BRANCH_NAME} "
224
+ }
225
+ }
226
+ echo " Deploy to ${ BRANCH_NAME} complete"
227
+ }
228
+ }
229
+ }
230
+ }
231
+
232
+ stage(' Research Hub Web steps' ) {
233
+ stages {
142
234
stage(' Build research-hub-web' ) {
143
235
when {
144
236
anyOf {
@@ -195,11 +287,7 @@ pipeline {
195
287
}
196
288
}
197
289
}
198
- }
199
- }
200
-
201
- stage(' Run tests' ) {
202
- stages {
290
+
203
291
stage(' Run research-hub-web tests' ) {
204
292
when {
205
293
anyOf {
@@ -219,48 +307,7 @@ pipeline {
219
307
}
220
308
}
221
309
}
222
- stage(' Run cer-graphql tests' ) {
223
- when {
224
- anyOf {
225
- changeset " **/cer-graphql/**/*.*"
226
- equals expected : true , actual : params. FORCE_REDEPLOY_CG
227
- }
228
- }
229
- steps {
230
- script {
231
- if (env. BRANCH_NAME != ' prod' ) { // tests rely on 2FAB so we do not test in prod
232
- echo ' Testing cer-graphql project'
233
- dir(' cer-graphql' ) {
234
- sh " npm install"
235
- sh " export stage=${ BRANCH_NAME} && npm run test -- --aws-profile=${ awsProfile} "
236
- }
237
- }
238
- }
239
- }
240
- }
241
- stage(' Run search-proxy tests' ) {
242
- when {
243
- anyOf {
244
- changeset " **/hub-search-proxy/**/*.*"
245
- equals expected : true , actual : params. FORCE_REDEPLOY_SP
246
- }
247
- }
248
- steps {
249
- script {
250
- if (env. BRANCH_NAME != ' prod' ) {
251
- echo " Testing hub-search-proxy project"
252
- dir(' hub-search-proxy' ) {
253
- sh " npm run test -- --aws-profile ${ awsProfile} --stage ${ env.BRANCH_NAME} "
254
- }
255
- }
256
- }
257
- }
258
- }
259
- }
260
- }
261
-
262
- stage(' Deploy projects' ) {
263
- parallel {
310
+
264
311
stage(' Deploy research-hub-web' ) {
265
312
when {
266
313
anyOf {
@@ -327,47 +374,6 @@ pipeline {
327
374
}
328
375
}
329
376
}
330
- stage(' Deploy cer-graphql' ) {
331
- when {
332
- anyOf {
333
- changeset " **/cer-graphql/**/*.*"
334
- equals expected : true , actual : params. FORCE_REDEPLOY_CG
335
- }
336
- }
337
- steps { // TODO: may need to modify commands once we have both dev & test in nonprod account
338
- echo ' Deploying cer-graphql image to ECR on ' + BRANCH_NAME
339
- echo " Logging in to ECR"
340
- sh " (aws ecr get-login --no-include-email --region ${ awsRegion} --profile=${ awsProfile} ) | /bin/bash"
341
-
342
- echo " Tagging built image with ECR tag"
343
- sh " docker tag cer-graphql:latest ${ awsAccountId} .dkr.ecr.${ awsRegion} .amazonaws.com/research-hub/cer-graphql-${ BRANCH_NAME} :latest"
344
-
345
- echo " Pushing built image to ECR"
346
- sh " docker push ${ awsAccountId} .dkr.ecr.${ awsRegion} .amazonaws.com/research-hub/cer-graphql-${ BRANCH_NAME} :latest"
347
-
348
- echo ' Deploying cer-graphql image from ECR to Fargate on ' + BRANCH_NAME
349
- sh " aws ecs update-service --profile ${ awsProfile} --cluster cer-graphql-cluster-${ BRANCH_NAME} --service cer-graphql-service-${ BRANCH_NAME} --task-definition cer-graphql-${ BRANCH_NAME} --force-new-deployment --region ${ awsRegion} "
350
- sh " aws ecs update-service --profile ${ awsProfile} --cluster cer-graphql-cluster-${ BRANCH_NAME} --service cer-graphql-preview-service-${ BRANCH_NAME} --task-definition cer-graphql-preview-${ BRANCH_NAME} --force-new-deployment --region ${ awsRegion} "
351
- }
352
- }
353
- stage(' Deploy search-proxy' ) {
354
- when {
355
- anyOf {
356
- changeset " **/hub-search-proxy/**/*.*"
357
- equals expected : true , actual : params. FORCE_REDEPLOY_SP
358
- }
359
- }
360
- steps {
361
- echo " Deploying hub-search-proxy Lambda function to ${ BRANCH_NAME} "
362
- script {
363
- dir(" hub-search-proxy" ) {
364
- sh " npm run deploy -- --aws-profile ${ awsProfile} --stage ${ BRANCH_NAME} "
365
- }
366
- }
367
- echo " Deploy to ${ BRANCH_NAME} complete"
368
-
369
- }
370
- }
371
377
}
372
378
}
373
379
}
0 commit comments