-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathJenkinsfile_CNP
More file actions
225 lines (190 loc) · 9.69 KB
/
Jenkinsfile_CNP
File metadata and controls
225 lines (190 loc) · 9.69 KB
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
#!groovy
@Library("Infrastructure")
import uk.gov.hmcts.contino.GradleBuilder
import uk.gov.hmcts.contino.GithubAPI
import uk.gov.hmcts.contino.AppPipelineDsl
def product = "ccd"
def component = "case-document-am-api"
def branchesToSync = ['demo', 'ithc', 'perftest']
GradleBuilder builder = new GradleBuilder(this, product)
// Variables to switch pipeline logic and wiring per type of build
def definitionStoreDevelopPr = "PR-575" // This doesn't change frequently, but when it does, only change this value.
def dataStoreApiDevelopPr = "PR-1260" // This doesn't change frequently, but when it does, only change this value.
def prsToUseAat = "PR-148" // Set this value to a PR number, or add it as a comma-separated value, if it's to follow CI/CD.
def secrets = [
'ccd-${env}': [
secret('ccd-caseworker-autotest-email', 'CCD_CASEWORKER_AUTOTEST_EMAIL'),
secret('ccd-caseworker-autotest-password', 'CCD_CASEWORKER_AUTOTEST_PASSWORD'),
secret('ccd-befta-caseworker-2-solicitor-1-pwd', 'CCD_BEFTA_CASEWORKER_2_SOLICITOR_1_PWD'),
secret('ccd-befta-caseworker-2-solicitor-2-pwd', 'CCD_BEFTA_CASEWORKER_2_SOLICITOR_2_PWD'),
secret('ccd-befta-caseworker-2-solicitor-3-pwd', 'CCD_BEFTA_CASEWORKER_2_SOLICITOR_3_PWD'),
secret('ccd-befta-caseworker-1-pwd', 'CCD_BEFTA_CASEWORKER_1_PWD'),
secret('ccd-befta-caseworker-2-pwd', 'CCD_BEFTA_CASEWORKER_2_PWD'),
secret('ccd-befta-caseworker-3-pwd', 'CCD_BEFTA_CASEWORKER_3_PWD'),
secret('ccd-befta-citizen-2-pwd', 'CCD_BEFTA_CITIZEN_2_PWD'),
secret('ccd-befta-citizen-3-pwd', 'CCD_BEFTA_CITIZEN_3_PWD'),
secret('ccd-befta-solicitor-3-pwd', 'CCD_BEFTA_SOLICITOR_3_PWD'),
secret('ccd-api-gateway-oauth2-client-secret', 'OAUTH2_CLIENT_SECRET'),
secret('ccd-api-gateway-oauth2-client-secret', 'CCD_API_GATEWAY_OAUTH2_CLIENT_SECRET'),
secret('definition-importer-username', 'DEFINITION_IMPORTER_USERNAME'),
secret('definition-importer-password', 'DEFINITION_IMPORTER_PASSWORD'),
],
's2s-${env}': [
secret('microservicekey-ccd-gw', 'BEFTA_S2S_CLIENT_SECRET'),
secret('microservicekey-ccd-data', 'BEFTA_S2S_CLIENT_SECRET_OF_CCD_DATA'),
secret('microservicekey-bulk-scan-processor', 'BEFTA_S2S_CLIENT_SECRET_OF_BULK_SCAN_PROCESSOR'),
secret('microservicekey-xui-webapp', 'BEFTA_S2S_CLIENT_SECRET_OF_XUI_WEBAPP')
]
]
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
version : '',
envVariable: envVar
]
}
// Vars needed for functional and smoke tests run against AKS
// Assume a feature build branched off 'develop', with dependencies develop-to-develop.
env.CCD_DATA_STORE_API_BASE_URL = "https://ccd-data-store-api-${dataStoreApiDevelopPr}.preview.platform.hmcts.net".toLowerCase()
env.DEFINITION_STORE_URL_BASE = "https://ccd-definition-store-api-${definitionStoreDevelopPr}.preview.platform.hmcts.net".toLowerCase()
env.IDAM_URL = "https://idam-api.aat.platform.hmcts.net"
env.S2S_URL = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.OAUTH2_CLIENT_ID = "ccd_gateway"
env.OAUTH2_REDIRECT_URI = "https://www-ccd.aat.platform.hmcts.net/oauth2redirect"
env.DM_STORE_BASE_URL = "http://dm-store-aat.service.core-compute-aat.internal"
env.CCD_API_GATEWAY_OAUTH2_CLIENT_ID = "ccd_gateway"
env.IDAM_API_URL_BASE = "https://idam-api.aat.platform.hmcts.net"
env.S2S_URL_BASE = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.BEFTA_S2S_CLIENT_ID = "ccd_gw"
env.BEFTA_S2S_CLIENT_ID_OF_CCD_DATA = "ccd_data"
env.BEFTA_S2S_CLIENT_ID_OF_XUI_WEBAPP = "xui_webapp"
env.BEFTA_S2S_CLIENT_ID_OF_BULK_SCAN_PROCESSOR = "bulk_scan_processor"
env.BEFTA_RESPONSE_HEADER_CHECK_POLICY = "JUST_WARN"
env.CCD_API_GATEWAY_S2S_ID = "ccd_gw"
env.CCD_API_GATEWAY_S2S_KEY = "AAAAAAAAAAAAAAAC"
env.PACT_BROKER_FULL_URL = "https://pact-broker.platform.hmcts.net"
env.PACT_BROKER_URL = "pact-broker.platform.hmcts.net"
env.PACT_BROKER_PORT = "443"
env.PACT_BROKER_SCHEME = "https"
// Prevent Docker hub rate limit errors by ensuring that testcontainers uses images from hmctsprod ACR
env.TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX = "hmctsprod.azurecr.io/imported/"
withPipeline("java", product, component) {
onMaster {
enablePactAs([
AppPipelineDsl.PactRoles.PROVIDER
])
}
onPR {
def githubApi = new GithubAPI(this)
enablePactAs([
AppPipelineDsl.PactRoles.PROVIDER
])
}
// Check if the build should be wired to an environment higher than 'preview'.
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'demo' || env.BRANCH_NAME == 'perftest' || env.BRANCH_NAME == 'ithc' || prsToUseAat.toLowerCase().contains(env.BRANCH_NAME.toLowerCase())) {
environmentOfDependencies = env.BRANCH_NAME
// use aat environment for dependencies of master and CI/CD builds.
if (env.BRANCH_NAME.startsWith("PR") || env.BRANCH_NAME == 'master') {
environmentOfDependencies = "aat"
}
env.CCD_DATA_STORE_API_BASE_URL = "http://ccd-data-store-api-${environmentOfDependencies}.service.core-compute-${environmentOfDependencies}.internal"
} else {
env.DEFINITION_STORE_URL_BASE = "https://ccd-definition-store-api-${definitionStoreDevelopPr}.service.core-compute-preview.internal".toLowerCase()
}
syncBranchesWithMaster(branchesToSync)
enableSlackNotifications('#ccd-case-document-am-api-builds')
loadVaultSecrets(secrets)
enableAksStagingDeployment()
disableLegacyDeployment()
afterAlways('test') {
builder.gradle('integration')
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/reports/checkstyle/*.html'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/reports/pmd/*.html'
copyIgnore('./build/reports/tests/integration', './Integration Tests/')
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/Integration Tests/**/*'
copyIgnore('./build/reports/tests/test', './Unit Tests/')
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/Unit Tests/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "Unit Tests",
reportFiles : "index.html",
reportName : "Unit Test Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "Integration Tests",
reportFiles : "index.html",
reportName : "Integration Test Report"
]
}
afterAlways('functionalTest:preview') {
copyIgnore('./build/reports/tests/befta/functional/cucumber-html-reports', './BEFTA Report for Functional Tests/')
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/BEFTA Report for Functional Tests/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : 'BEFTA Report for Functional Tests',
reportFiles : "overview-features.html",
reportName : "Functional Test Report"
]
}
afterAlways('functionalTest:aat') {
copyIgnore('./build/reports/tests/befta/functional/cucumber-html-reports', './BEFTA Report for Functional Tests/')
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/BEFTA Report for Functional Tests/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : 'BEFTA Report for Functional Tests',
reportFiles : "overview-features.html",
reportName : "Functional Test Report"
]
}
afterAlways('smoketest:preview') {
copyIgnore('./build/reports/tests/befta/smoke/cucumber-html-reports', './BEFTA Report for Smoke Tests/')
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/BEFTA Report for Smoke Tests/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : 'BEFTA Report for Smoke Tests',
reportFiles : "overview-features.html",
reportName : "Smoke Test Report"
]
}
afterAlways('smoketest:aat') {
copyIgnore('./build/reports/tests/befta/smoke/cucumber-html-reports', './BEFTA Report for Smoke Tests/')
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/BEFTA Report for Smoke Tests/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : 'BEFTA Report for Smoke Tests',
reportFiles : "overview-features.html",
reportName : "Smoke Test Report"
]
}
afterAlways('pact-provider-verification') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/runProviderPactVerification",
reportFiles : "index.html",
reportName : "Contract Tests Report"
]
}
}
/**
* Forces a recursive copy by always returning 0 regardless of errors
*/
def copyIgnore(filePath, destinationDir) {
steps.sh("cp -R '${filePath}' '${destinationDir}' || :")
}