This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile_CNP
290 lines (254 loc) · 10.6 KB
/
Jenkinsfile_CNP
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
#!groovy
@Library("Infrastructure")
import uk.gov.hmcts.contino.AppPipelineDsl
import uk.gov.hmcts.contino.GradleBuilder
import uk.gov.hmcts.contino.AppPipelineConfig
import uk.gov.hmcts.contino.MetricsPublisher
def type = "java"
def product = "sptribs"
def component = "dss-backend"
GradleBuilder builder = new GradleBuilder(this, product)
static Map<String, Object> secret(String secretName, String envVariable) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
envVariable: envVariable
]
}
def secrets = [
's2s-${env}' : [
secret('microservicekey-ccd-data', 'DATA_STORE_S2S_KEY'),
secret('microservicekey-ccd-definition', 'DEFINITION_STORE_S2S_KEY'),
secret('microservicekey-ccd-gw', 'CCD_API_GATEWAY_S2S_KEY'),
secret('microservicekey-ccd-admin', 'ADMIN_S2S_KEY'),
secret('microservicekey-ccd-data', 'CCD_DATA_STORE_S2S_SECRET'),
secret('microservicekey-ccd-definition', 'CCD_DEFINITION_STORE_S2S_SECRET')
],
'ccd-${env}' : [
secret('ccd-api-gateway-oauth2-client-secret', 'CCD_API_GATEWAY_OAUTH2_CLIENT_SECRET'),
secret('ccd-admin-web-oauth2-client-secret', 'ADMIN_WEB_IDAM_SECRET'),
secret('postcode-info-address-lookup-token', 'ADDRESS_LOOKUP_TOKEN'),
secret('idam-data-store-client-secret','IDAM_OAUTH2_DATA_STORE_CLIENT_SECRET'),
secret('idam-data-store-system-user-username','IDAM_DATA_STORE_SYSTEM_USER_USERNAME'),
secret('idam-data-store-system-user-password','IDAM_DATA_STORE_SYSTEM_USER_PASSWORD'),
],
'sptribs-aat' :[
secret('definition-importer-username', 'DEFINITION_IMPORTER_USERNAME'),
secret('definition-importer-password', 'DEFINITION_IMPORTER_PASSWORD'),
secret('idam-ui-secret', 'OAUTH2_CLIENT_SECRET'),
secret('idam-solicitor-username', 'IDAM_SOLICITOR_USERNAME'),
secret('idam-solicitor-password', 'IDAM_SOLICITOR_PASSWORD'),
secret('idam-systemupdate-username', 'IDAM_SYSTEM_UPDATE_USERNAME'),
secret('idam-systemupdate-password', 'IDAM_SYSTEM_UPDATE_PASSWORD'),
secret('s2s-secret-sptribs-dss-backend', 'S2S_SECRET'),
secret('app-insights-instrumentation-key', 'APP_INSIGHTS_KEY'),
]
]
def pipelineConf = new AppPipelineConfig()
pipelineConf.vaultSecrets = secrets
def vaultOverrides = [
'preview': 'aat',
'prod': 'aat',
]
withPipeline(type, product, component) {
enableAksStagingDeployment()
disableLegacyDeployment()
overrideVaultEnvironments(vaultOverrides)
loadVaultSecrets(secrets)
syncBranchesWithMaster(['demo', 'ithc', 'perftest'])
enableSlackNotifications('#family-integration-devsch') //?
MetricsPublisher metricsPublisher = new MetricsPublisher(this, currentBuild, product, component )
approvedEnvironmentRepository(params.environment, metricsPublisher) {
if(params.environment != 'prod') {
enableHighLevelDataSetup()
}
}
afterAlways('test') {
builder.gradle('integration')
builder.gradle('jacocoTestReport')
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/checkstyle",
reportFiles : "main.html",
reportName : "Checkstyle Main Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/checkstyle",
reportFiles : "test.html",
reportName : "Checkstyle Test Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/checkstyle",
reportFiles : "functionalTest.html",
reportName : "Checkstyle Functional Test Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/checkstyle",
reportFiles : "integrationTest.html",
reportName : "Checkstyle Integration Test Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/test",
reportFiles : "index.html",
reportName : "Unit Tests Report"
]
}
afterAlways('functionalTest:preview') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/functional",
reportFiles : "index.html",
reportName : "Functional Tests Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "target/site/serenity/",
reportFiles : "index.html",
reportName : "Functional Tests Report"
]
dir("${WORKSPACE}") {
steps.archiveArtifacts artifacts: "**/*"
}
}
afterAlways('functionalTest:aat') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/functional",
reportFiles : "index.html",
reportName : "Functional Tests Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "target/site/serenity/",
reportFiles : "index.html",
reportName : "Functional Tests Report"
]
dir("${WORKSPACE}") {
steps.archiveArtifacts artifacts: "**/*"
}
}
afterAlways('smokeTest:preview') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/smoke",
reportFiles : "index.html",
reportName : "Smoke Test Report"
]
}
afterAlways('smokeTest:aat') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/smoke",
reportFiles : "index.html",
reportName : "Smoke Test Report"
]
}
afterAlways('checkout') {
builder.gradle('generateCCDConfig')
generateDefinitions()
}
onPR {
env.ENVIRONMENT="preview"
env.CASE_API_URL = "http://sptribs-dss-backend-pr-${CHANGE_ID}.service.core-compute-preview.internal"
env.CCD_DEF_NAME = "preview"
env.DEFINITION_STORE_URL_BASE = "https://ccd-definition-store-sptribs-dss-backend-pr-${CHANGE_ID}.service.core-compute-preview.internal"
env.CASE_DATA_STORE_BASEURL = "http://ccd-data-store-api-sptribs-dss-backend-pr-${CHANGE_ID}.service.core-compute-preview.internal"
env.S2S_URL_BASE = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.IDAM_API_URL_BASE = "https://idam-api.aat.platform.hmcts.net"
env.CITIZEN_UPDATE_CASE_STATE_ENABLED=true
env.PACT_BROKER_FULL_URL = 'https://pact-broker.platform.hmcts.net'
enablePactAs([AppPipelineDsl.PactRoles.CONSUMER])
setCommonEnvVariables()
}
onMaster {
env.ENVIRONMENT="aat"
env.CASE_API_URL="http://sptribs-dss-backend-aat.service.core-compute-aat.internal"
env.CCD_DEF_NAME="aat"
env.DEFINITION_STORE_URL_BASE="http://ccd-definition-store-api-aat.service.core-compute-aat.internal"
env.CITIZEN_UPDATE_CASE_STATE_ENABLED=true
env.PACT_BROKER_FULL_URL = 'https://pact-broker.platform.hmcts.net'
enablePactAs([AppPipelineDsl.PactRoles.CONSUMER])
setCommonEnvVariables()
}
onDemo {
env.ENVIRONMENT="demo"
env.CASE_API_URL = "http://sptribs-dss-backend-demo.service.core-compute-demo.internal"
env.CCD_DEF_NAME = "demo"
env.IDAM_API_URL_BASE = "https://idam-api.demo.platform.hmcts.net"
env.S2S_URL_BASE = "http://rpe-service-auth-provider-demo.service.core-compute-demo.internal"
env.DEFINITION_STORE_URL_BASE = "http://ccd-definition-store-api-demo.service.core-compute-demo.internal"
}
onPerftest {
env.ENVIRONMENT="perftest"
env.CASE_API_URL = "http://sptribs-dss-backend-perftest.service.core-compute-perftest.internal"
env.CCD_DEF_NAME = "perftest"
env.IDAM_API_URL_BASE = "https://idam-api.perftest.platform.hmcts.net"
env.S2S_URL_BASE = "http://rpe-service-auth-provider-perftest.service.core-compute-perftest.internal"
env.DEFINITION_STORE_URL_BASE = "http://ccd-definition-store-api-perftest.service.core-compute-perftest.internal"
}
onIthc {
env.ENVIRONMENT="ithc"
env.CASE_API_URL = "http://sptribs-dss-backend-ithc.service.core-compute-ithc.internal"
env.CCD_DEF_NAME = "ithc"
env.IDAM_API_URL_BASE = "https://idam-api.ithc.platform.hmcts.net"
env.S2S_URL_BASE = "http://rpe-service-auth-provider-ithc.service.core-compute-ithc.internal"
env.DEFINITION_STORE_URL_BASE = "http://ccd-definition-store-api-ithc.service.core-compute-ithc.internal"
}
before('functionalTest:preview') {
// Only for preview upload the definitions via script as high level data set up relies on an existing environment
uploadCoreCaseDataDefinitions()
}
}
env.PACT_BROKER_FULL_URL = 'https://pact-broker.platform.hmcts.net'
def setCommonEnvVariables() {
env.IDAM_API_URL_BASE = "https://idam-api.aat.platform.hmcts.net"
env.IDAM_API_BASEURL = "https://idam-api.aat.platform.hmcts.net"
env.S2S_URL_BASE = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.CCD_API_GATEWAY_OAUTH2_CLIENT_ID = "ccd_gateway"
env.BEFTA_S2S_CLIENT_ID = "ccd_data"
env.CCD_API_GATEWAY_OAUTH2_REDIRECT_URL = "https://www-ccd.aat.platform.hmcts.net/oauth2redirect"
env.TEST_S2S_URL = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
}
def uploadCoreCaseDataDefinitions() {
dir("${WORKSPACE}/bin"){
sh "./add-roles.sh"
sh "./process-and-import-ccd-definition.sh"
}
dir("${WORKSPACE}") {
steps.archiveArtifacts artifacts: "build/ccd-config/*.xlsx"
}
}
def generateDefinitions() {
dir("${WORKSPACE}/bin") {
sh "./ccd-build-definition.sh"
}
dir("${WORKSPACE}") {
steps.archiveArtifacts artifacts: "build/ccd-config/*.xlsx"
}
}