-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile_nightly
255 lines (232 loc) · 12.9 KB
/
Jenkinsfile_nightly
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
#!groovy
properties([
// H allow predefined but random minute see https://en.wikipedia.org/wiki/Cron#Non-standard_characters
pipelineTriggers([cron('H 8 * * 1-5')]),
parameters([
string(name: 'URL_TO_TEST', defaultValue: 'http://ia-case-api-aat.service.core-compute-aat.internal', description: 'The URL you want to run these tests against'),
string(name: 'SecurityRules',
defaultValue: 'https://raw.githubusercontent.com/hmcts/security-test-rules/master/conf/security-rules.conf',
description: 'The URL you want to run these tests against'),
booleanParam(name: 'skipSmokeTest', defaultValue: false, description: 'Tick the checkbox to skip Smoke Test stage'),
booleanParam(name: 'skipUnitTests', defaultValue: false, description: 'Tick the checkbox to skip Unit Tests stage'),
booleanParam(name: 'skipIntegrationTests', defaultValue: false, description: 'Tick the checkbox to skip Integration Tests stage'),
booleanParam(name: 'skipFortifyScan', defaultValue: false, description: 'Tick the checkbox to skip Fortify Scan stage'),
booleanParam(name: 'skipSecurityScan', defaultValue: false, description: 'Tick the checkbox to skip Security Scan stage'),
booleanParam(name: 'skipMutationTests', defaultValue: false, description: 'Tick the checkbox to skip Mutation Tests stage'),
booleanParam(name: 'skipFullFunctionalTests', defaultValue: false, description: 'Tick the checkbox to skip Full Functional Tests stage'),
])
])
@Library("Infrastructure")
import uk.gov.hmcts.contino.GradleBuilder
def type = "java"
def product = "ia"
def component = "case-api"
def secrets = [
'ia-${env}': [
secret('test-caseofficer-username', 'TEST_CASEOFFICER_USERNAME'),
secret('test-caseofficer-password', 'TEST_CASEOFFICER_PASSWORD'),
secret('test-law-firm-a-username', 'TEST_LAW_FIRM_A_USERNAME'),
secret('test-law-firm-a-password', 'TEST_LAW_FIRM_A_PASSWORD'),
secret('test-adminofficer-username', 'TEST_ADMINOFFICER_USERNAME'),
secret('test-adminofficer-password', 'TEST_ADMINOFFICER_PASSWORD'),
secret('addressLookupToken', 'ADDRESS_LOOKUP_TOKEN'),
secret('pcq-token-key', 'PCQ_TOKEN_KEY'),
secret('ia-redis-access-key', 'IA_REDIS_ACCESS_KEY'),
secret('ia-redis-connection-string', 'IA_REDIS_CONNECTION_STRING'),
secret('homeoffice-client-id', 'IA_HOMEOFFICE_CLIENT_ID'),
secret('homeoffice-secret', 'IA_HOMEOFFICE_SECRET'),
secret('test-homeoffice-apc-username', 'TEST_HOMEOFFICE_APC_USERNAME'),
secret('test-homeoffice-apc-password', 'TEST_HOMEOFFICE_APC_PASSWORD'),
secret('test-homeoffice-lart-username', 'TEST_HOMEOFFICE_LART_USERNAME'),
secret('test-homeoffice-lart-password', 'TEST_HOMEOFFICE_LART_PASSWORD'),
secret('test-homeoffice-pou-username', 'TEST_HOMEOFFICE_POU_USERNAME'),
secret('test-homeoffice-pou-password', 'TEST_HOMEOFFICE_POU_PASSWORD'),
secret('test-homeoffice-generic-username', 'TEST_HOMEOFFICE_GENERIC_USERNAME'),
secret('test-homeoffice-generic-password', 'TEST_HOMEOFFICE_GENERIC_PASSWORD'),
secret('test-judge-x-username', 'TEST_JUDGE_X_USERNAME'),
secret('test-judge-x-password', 'TEST_JUDGE_X_PASSWORD'),
secret('test-law-firm-share-case-a-username', 'TEST_LAW_FIRM_SHARE_CASE_A_USERNAME'),
secret('test-law-firm-share-case-a-password', 'TEST_LAW_FIRM_SHARE_CASE_A_PASSWORD'),
secret('test-citizen-username', 'TEST_CITIZEN_USERNAME'),
secret('test-citizen-password', 'TEST_CITIZEN_PASSWORD'),
secret('test-law-firm-org-success-username', 'TEST_LAW_FIRM_ORG_SUCCESS_USERNAME'),
secret('test-law-firm-org-success-password', 'TEST_LAW_FIRM_ORG_SUCCESS_PASSWORD'),
secret('test-law-firm-org-deleted-username', 'TEST_LAW_FIRM_ORG_DELETED_USERNAME'),
secret('test-law-firm-org-deleted-password', 'TEST_LAW_FIRM_ORG_DELETED_PASSWORD'),
secret('idam-client-id', 'IA_IDAM_CLIENT_ID'),
secret('idam-secret', 'IA_IDAM_SECRET'),
secret('s2s-secret', 'IA_S2S_SECRET'),
secret('s2s-microservice', 'IA_S2S_MICROSERVICE'),
secret('prof-ref-data-url', 'PROF_REF_DATA_URL'),
secret('docmosis-enabled', 'IA_DOCMOSIS_ENABLED'),
secret('em-stitching-enabled', 'IA_EM_STITCHING_ENABLED'),
secret('submit-hearing-requirements-enabled', 'IA_SUBMIT_HEARING_REQUIREMENTS_ENABLED'),
secret('launch-darkly-sdk-key', 'LAUNCH_DARKLY_SDK_KEY'),
secret('app-insights-connection-string', 'app-insights-connection-string'),
secret('postgres-auth-values-password', 'PG_AUTH_VALUES_YAML_PASS'),
secret('generic-values-preview-password', 'GENERIC_VALUES_PREVIEW_YAML_PASS'),
secret('generic-docker-pact-broker-password', 'GENERIC_DOCKER_PACT_BROKER_YAML_PASS'),
secret('hearing-centre-activation-date-bradford', 'IA_HEARING_CENTRE_ACTIVATION_DATE_BRADFORD'),
secret('hearing-centre-activation-date-manchester', 'IA_HEARING_CENTRE_ACTIVATION_DATE_MANCHESTER'),
secret('hearing-centre-activation-date-newport', 'IA_HEARING_CENTRE_ACTIVATION_DATE_NEWPORT'),
secret('hearing-centre-activation-date-taylor-house', 'IA_HEARING_CENTRE_ACTIVATION_DATE_TAYLOR_HOUSE'),
secret('hearing-centre-activation-date-north-shields', 'IA_HEARING_CENTRE_ACTIVATION_DATE_NORTH_SHIELDS'),
secret('hearing-centre-activation-date-birmingham', 'IA_HEARING_CENTRE_ACTIVATION_DATE_BIRMINGHAM'),
secret('hearing-centre-activation-date-hatton-cross', 'IA_HEARING_CENTRE_ACTIVATION_DATE_HATTON_CROSS'),
secret('hearing-centre-activation-date-glasgow', 'IA_HEARING_CENTRE_ACTIVATION_DATE_GLASGOW'),
secret('servicesatcdmiac-password', 'CCD_UPLOAD_PASSWORD'),
secret('ccd-client-secret', 'CCD_CLIENT_SECRET')
]
]
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
version : '',
envVariable: envVar
]
}
GradleBuilder builder = new GradleBuilder(this, product)
withNightlyPipeline(type, product, component) {
env.TEST_URL = params.URL_TO_TEST
env.Rules = params.SecurityRules
env.IA_CASE_DOCUMENTS_API_URL = "http://ia-case-documents-api-aat.service.core-compute-aat.internal/"
env.IA_CASE_NOTIFICATIONS_API_URL = "http://ia-case-notifications-api-aat.service.core-compute-aat.internal/"
env.IA_TIMED_EVENT_SERVICE_URL = "http://ia-timed-event-service-aat.service.core-compute-aat.internal/"
env.IA_CASE_PAYMENTS_API_URL = "http://ia-case-payments-api-aat.service.core-compute-aat.internal/"
env.IA_HOME_OFFICE_INTEGRATION_API_URL = "http://ia-home-office-integration-api-aat.service.core-compute-aat.internal/"
env.IA_IDAM_REDIRECT_URI = "https://ia-case-api-aat.service.core-compute-aat.internal/oauth2/callback"
env.CCD_URL = "http://ccd-data-store-api-aat.service.core-compute-aat.internal"
env.CCD_GW_URL = "http://dm-store-aat.service.core-compute-aat.internal"
env.DM_URL = "http://dm-store-aat.service.core-compute-aat.internal"
env.IDAM_URL = "https://idam-api.aat.platform.hmcts.net"
env.OPEN_ID_IDAM_URL = "https://idam-web-public.aat.platform.hmcts.net"
env.S2S_URL = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.CASE_DOCUMENT_AM_URL = "http://ccd-case-document-am-api-aat.service.core-compute-aat.internal"
env.IS_SAVE_AND_CONTINUE_ENABLED = "false"
env.LOCATION_REF_DATA_URL = "http://rd-location-ref-api-aat.service.core-compute-aat.internal"
loadVaultSecrets(secrets)
if (!params.skipFortifyScan) {
enableFortifyScan()
}
if (!params.skipSecurityScan) {
enableSecurityScan()
}
if (!params.skipMutationTests) {
enableMutationTest()
}
if (!params.skipFullFunctionalTests) {
enableFullFunctionalTest()
}
enableSlackNotifications('#ia-tech')
afterAlways('build') {
if (!params.skipSmokeTest) {
stage('Smoke Test') {
try {
builder.gradle("smoke")
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable")
} finally {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/smoke",
reportFiles : "index.html",
reportName : "Smoke Test Report"
]
}
}
}
if (!params.skipUnitTests) {
stage('Unit Tests') {
try {
builder.gradle('test')
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable")
} finally {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/test",
reportFiles : "index.html",
reportName : "Unit Test Report"
]
}
}
}
if (!params.skipIntegrationTests) {
stage('Integration Tests') {
try {
builder.gradle('integration')
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable")
} finally {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/integration",
reportFiles : "index.html",
reportName : "Integration Test Report"
]
}
}
}
}
afterAlways('DependencyCheckNightly') {
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports",
reportFiles : 'dependency-check-report.html',
reportName : 'Dependency Check Report'
])
}
afterAlways('fortify-scan') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "Fortify Scan",
reportFiles : "FortifyScanReport.html",
reportName : "Fortify Scan Report"
]
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/Fortify Scan/**/*'
}
afterAlways('securityScan') {
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "functional-output",
reportFiles : 'api-report.html',
reportName : 'Security Scan Report'
])
}
afterAlways('mutationTest') {
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/pitest",
reportFiles : 'index.html',
reportName : 'Mutation Test Report'
])
}
afterAlways('fullFunctionalTest') {
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/functional",
reportFiles : 'index.html',
reportName : 'Functional Test Report'
])
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/site/serenity/**/*'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/build/reports/**/*'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/reports/**/*'
}
}