Repository navigation
Expand file tree
/
Copy pathJenkinsfile_CNP
More file actions
230 lines (201 loc) · 8.91 KB
/
Copy pathJenkinsfile_CNP
File metadata and controls
230 lines (201 loc) · 8.91 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
226
227
228
229
230
#!groovy
properties(
[
[
$class : 'GithubProjectProperty',
projectUrlStr: 'https://github.com/hmcts/am-role-assignment-service'
],
pipelineTriggers([[$class: 'GitHubPushTrigger']])
]
)
@Library("Infrastructure@2.5.4")
import uk.gov.hmcts.contino.AppPipelineDsl
def type = "java"
def product = "am"
def component = "role-assignment-service"
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
version : '',
envVariable: envVar
]
}
def vaultOverrides = [
'preview' : 'aat',
'spreview': 'saat'
]
//These secrets will be available in the functional tests in the virtual machine where pipeline executes.
def secrets = [
's2s-${env}': [
secret('microservicekey-aac-manage-case-assignment', 'BEFTA_S2S_CLIENT_SECRET_OF_AAC_MANAGE_CASE_ASSIGNMENT'),
secret('microservicekey-am-role-assignment-service', 'AM_ROLE_ASSIGNMENT_SERVICE_SECRET'),
secret('microservicekey-am-role-assignment-service', 'BEFTA_S2S_CLIENT_SECRET'),
secret('microservicekey-am-org-role-mapping-service', 'BEFTA_S2S_CLIENT_SECRET_OF_AM_ORG_ROLE_MAPPING_SERVICE'),
secret('microservicekey-ccd-case-disposer', 'BEFTA_S2S_CLIENT_SECRET_OF_CCD_CASE_DISPOSER'),
secret('microservicekey-ccd-data', 'BEFTA_S2S_CLIENT_SECRET_OF_CCD_DATA'),
secret('microservicekey-xui-webapp', 'BEFTA_S2S_CLIENT_SECRET_OF_XUI_WEBAPP')
],
'am-${env}': [
secret('role-assignment-service-IDAM-CLIENT-SECRET', 'ROLE_ASSIGNMENT_IDAM_CLIENT_SECRET'),
secret('test-am-user1-befta-pwd', 'TEST_AM_USER1_BEFTA_PWD'),
secret('test-am-user2-befta-pwd', 'TEST_AM_USER2_BEFTA_PWD'),
secret('test-am-user3-befta-pwd', 'TEST_AM_USER3_BEFTA_PWD'),
secret('role-assignment-service-IDAM-CLIENT-SECRET', 'OAUTH2_CLIENT_SECRET')
]
]
// Configure branches to sync with master branch
def branchesToSync = ['demo', 'ithc']
// Vars needed for functional and smoke tests to run against AKS
env.IDAM_URL = "https://idam-api.aat.platform.hmcts.net"
env.IDAM_API_URL_BASE = "https://idam-api.aat.platform.hmcts.net"
env.IDAM_S2S_URL = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.DEFINITION_STORE_HOST = "http://ccd-definition-store-api-aat.service.core-compute-aat.internal"
env.DEFINITION_STORE_URL_BASE = "http://ccd-definition-store-api-aat.service.core-compute-aat.internal"
env.CCD_DATA_STORE_URL = "http://ccd-data-store-api-aat.service.core-compute-aat.internal"
env.BEFTA_RETRY_MAX_ATTEMPTS = "3"
env.BEFTA_RETRY_STATUS_CODES = "502,503,504"
env.BEFTA_RETRY_MAX_DELAY = "1000"
env.BEFTA_S2S_CLIENT_ID = "am_role_assignment_service"
env.BEFTA_S2S_CLIENT_ID_OF_AAC_MANAGE_CASE_ASSIGNMENT = "aac_manage_case_assignment"
env.BEFTA_S2S_CLIENT_ID_OF_AM_ORG_ROLE_MAPPING_SERVICE = "am_org_role_mapping_service"
env.BEFTA_S2S_CLIENT_ID_OF_CCD_CASE_DISPOSER = "ccd_case_disposer"
env.BEFTA_S2S_CLIENT_ID_OF_CCD_DATA = "ccd_data"
env.BEFTA_S2S_CLIENT_ID_OF_XUI_WEBAPP = "xui_webapp"
env.OAUTH2_CLIENT_ID = "am_role_assignment"
env.OAUTH2_REDIRECT_URI = "http://am-role-assignment-service-aat.service.core-compute-aat.internal/oauth2redirect"
env.OAUTH2_ACCESS_TOKEN_TYPE = "OIDC"
env.BEFTA_RESPONSE_HEADER_CHECK_POLICY = "JUST_WARN"
env.S2S_URL = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.S2S_URL_BASE = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.OAUTH2_SCOPE_VARIABLES = "openid%20profile%20roles%20authorities"
env.IDAM_CLIENT_ID="am_role_assignment"
env.OPENID_SCOPE_VARIABLES = "openid+profile+roles+authorities"
env.MICROSERVICE_NAME = "am_role_assignment_service"
env.EXTERNAL_FLAG_QUERY_PATH = "am/role-assignments/fetchFlagStatus?flagName="
// Vars for Kubernetes PACT
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"
// Var to turn FTAs that rely on the RAS-CCD case validation on/off, i.e. when CCD is not available.
env.AZURE_CASE_VALIDATION_FTA_ENABLED = "true"
env.PCS_CASE_VALIDATION_FTA_ENABLED = "false" // temporarily disabled until we have a stable PCS environment to run these tests against
// Vars for Azure Container Registries DTSAM-370
env.TESTCONTAINERS_HOST_OVERRIDE="localhost"
env.TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX="hmctsprod.azurecr.io/imported/"
withPipeline(type, product, component) {
onMaster {
enableSlackNotifications('#am-master-builds')
}
if (env.BRANCH_NAME.startsWith("PR")) {
env.RAS_ENV = "pr"
}
else if(env.BRANCH_NAME == 'master') {
env.RAS_ENV = "aat"
}
else {
env.RAS_ENV = env.BRANCH_NAME
}
onPR {
enableSlackNotifications('#am-master-builds')
}
overrideVaultEnvironments(vaultOverrides)
loadVaultSecrets(secrets)
enableAksStagingDeployment()
disableLegacyDeploymentOnAAT()
disableLegacyDeployment()
enableDbMigration('am')
// Sync environment specific branches with master branch
syncBranchesWithMaster(branchesToSync)
afterAlways('test') {
// jenkins may fail to copy artifacts after some failures
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/test-results/test/*.xml'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/test-results/integration/*.xml'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/checkstyle",
reportFiles : "main.html,contractTest.html,functionalTest.html,integrationTest.html,smokeTest.html,test.html",
reportTitles : "Main,Contract Test,Functional Test,Integration Test,Smoke Test,Unit Test",
reportName : "Checkstyle Reports"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/test",
reportFiles : "index.html",
reportTitles : "Index",
reportName : "Unit Test Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/integration",
reportFiles : "index.html",
reportTitles : "Index",
reportName : "Integration Test Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/test-results/DroolTests",
reportFiles : "CaseAllocation/index.html,ChallengedAccess/index.html,PrmConfig/index.html",
reportTitles : "Case-Allocation,Challenged-Access,PRM Config",
reportName : "Drool Integration Test Report"
]
}
before('functionalTest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/integration/**/*'
}
before('functionalTest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/integration/**/*'
}
afterAlways('functionalTest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/cucumber/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "target/cucumber/functional-html-reports",
reportFiles : "overview-features.html,overview-failures.html,",
reportTitles : "Features,Failures",
reportName : "Functional Test Report"
]
}
afterAlways('functionalTest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/cucumber/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "target/cucumber/functional-html-reports",
reportFiles : "overview-features.html,overview-failures.html,",
reportTitles : "Features,Failures",
reportName : "Functional Test Report"
]
}
afterAlways('smoketest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/site/serenity/**'
}
afterAlways('smoketest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/site/serenity/**'
}
afterAlways('pact-provider-verification') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/**/*'
}
onMaster(){
enablePactAs([
AppPipelineDsl.PactRoles.PROVIDER
])
}
onPR(){
enablePactAs([
AppPipelineDsl.PactRoles.PROVIDER
])
}
}