-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile_CNP
170 lines (150 loc) · 6.94 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
#!groovy
@Library("Infrastructure")
import uk.gov.hmcts.contino.AppPipelineConfig
import uk.gov.hmcts.contino.AppPipelineDsl
import uk.gov.hmcts.contino.GithubAPI
def type = "java"
def product = "civil"
def component = "service"
def ccdBranch = "master"
def camundaBranch = "master"
def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this)
AppPipelineConfig pipelineConf
def getFunctionalTestsGroups() {
def githubApi = new GithubAPI(this)
def functionalTestGroups = []
for (label in githubApi.getLabelsbyPattern(env.BRANCH_NAME, "pr_ft_") ) {
functionalTestGroups.add(label.substring(6, label.length()))
}
return functionalTestGroups.join(",")
}
static Map<String, Object> secret(String secretName, String envVariable) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
envVariable: envVariable
]
}
def secrets = [
's2s-${env}': [
secret('microservicekey-ccd-gw', 'CCD_API_GATEWAY_S2S_SECRET'),
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_IDAM_CLIENT_SECRET'),
secret('ccd-api-gateway-oauth2-client-secret', 'CCD_API_GATEWAY_OAUTH2_CLIENT_SECRET'),
secret('postcode-info-address-lookup-token', 'ADDRESS_LOOKUP_TOKEN'),
secret('ccd-admin-web-oauth2-client-secret', 'ADMIN_WEB_IDAM_SECRET'),
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'),
secret('microservicekey-ccd-gw', 'CCD_API_GATEWAY_S2S_KEY')
],
'civil-${env}': [
secret('microservicekey-civil-service', 'S2S_SECRET'),
secret('ccd-importer-username', 'CCD_CONFIGURER_IMPORTER_USERNAME'),
secret('ccd-importer-password', 'CCD_CONFIGURER_IMPORTER_PASSWORD'),
secret('postgres-user', 'POSTGRES_USER'),
secret('postgres-password', 'POSTGRES_PASSWORD'),
secret('default-password','DEFAULT_PASSWORD'),
secret('judge-default-password','JUDGE_DEFAULT_PASSWORD'),
secret('iac-default-password','IAC_DEFAULT_PASSWORD'),
secret('system-update-user-password', 'SYSTEM_USER_PASSWORD'),
secret('generic-docker-pact-broker-password', 'GENERIC_DOCKER_PACT_BROKER_YAML_PASS')
],
'aac-${env}': [
secret('idam-mca-client-secret', 'IDAM_MCA_CLIENT_SECRET'),
secret('idam-mca-system-user-username', 'IDAM_CAA_USERNAME'),
secret('idam-mca-system-user-password', 'IDAM_CAA_PASSWORD'),
secret('idam-noc-approver-username', 'IDAM_NOC_APPROVER_USERNAME'),
secret('idam-noc-approver-password', 'IDAM_NOC_APPROVER_PASSWORD'),
secret('aac-manage-case-s2s-secret', 'MANAGE_CASE_S2S_KEY'),
secret('notify-mca-api-key-secret', 'NOTIFY_MCA_API_KEY')
],
]
// Vars for Kubernetes
env.PACT_BROKER_FULL_URL = 'https://pact-broker.platform.hmcts.net'
env.EM_CCD_ORCHESTRATOR_URL = 'http://em-ccd-orchestrator-aat.service.core-compute-aat.internal'
def checkForEnableHelmLabel(branch_name) {
return new GithubAPI(this).getLabelsbyPattern(branch_name, "pr-values: enableHelm").contains("pr-values: enableHelm")
}
withPipeline(type, product, component) {
onPR {
enablePactAs([AppPipelineDsl.PactRoles.CONSUMER])
env.ENVIRONMENT = "preview"
env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
loadVaultSecrets(secrets)
before('build') {
sh """
./bin/validate-migration-files.sh ${env.CHANGE_BRANCH} ${env.CHANGE_TARGET} --jenkins
"""
}
}
onMaster {
enablePactAs([AppPipelineDsl.PactRoles.CONSUMER])
env.ENVIRONMENT = "aat"
loadVaultSecrets(secrets)
}
onDemo {
loadVaultSecrets(secrets)
}
before('smoketest:preview') {
env.URL="https://xui-civil-service-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.CIVIL_SERVICE_URL="https://civil-service-pr-${CHANGE_ID}.preview.platform.hmcts.net"
retry (3) {
sh """
eval \$(./bin/variables/load-preview-environment-variables.sh ${CHANGE_ID})
./bin/wait-for.sh definition-store
./bin/add-roles.sh
./bin/pull-latest-camunda-files.sh ${camundaBranch}
./bin/pull-latest-ccd-files.sh ${ccdBranch}
./bin/import-ccd-definition.sh "-e *-prod.json,*HNL-nonprod.json,AuthorisationCaseType-shuttered.json"
"""
}
yarnBuilder.yarn('yarn-update')
yarnBuilder.yarn('install-dependencies')
env.IDAM_API_URL = "https://idam-api.aat.platform.hmcts.net"
env.SERVICE_AUTH_PROVIDER_API_BASE_URL = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.CCD_DATA_STORE_URL = "https://ccd-data-store-api-civil-service-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.DM_STORE_URL = "http://dm-store-aat.service.core-compute-aat.internal"
env.AAC_API_URL="https://manage-case-assignment-civil-service-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.WIREMOCK_URL="https://wiremock-civil-service-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.PR_FT_GROUPS = getFunctionalTestsGroups()
}
afterAlways('smoketest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'test-results/smokeTest/**/*'
if (checkForEnableHelmLabel(env.BRANCH_NAME)) {
error "The 'pr-values: enableHelm' label is active on the PR. The build will be interrupted to avoid wasting build time needlessly."
}
}
afterAlways('functionalTest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'test-results/functional/**/*'
}
before('smoketest:aat') {
sh """
eval \$(./bin/variables/load-staging-environment-variables.sh)
./bin/add-roles.sh
./bin/pull-latest-camunda-files.sh ${camundaBranch}
./bin/pull-latest-ccd-files.sh ${ccdBranch}
./bin/import-ccd-definition.sh "-e *-nonprod.json,*COS-nonprod.json,AuthorisationCaseType-shuttered.json"
./bin/import-bpmn-diagram.sh .
"""
env.URL="https://civil-service-xui-staging.aat.platform.hmcts.net"
env.CIVIL_SERVICE_URL="https://civil-service-staging.aat.platform.hmcts.net"
env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
env.IDAM_API_URL = "https://idam-api.aat.platform.hmcts.net"
env.SERVICE_AUTH_PROVIDER_API_BASE_URL = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.CCD_DATA_STORE_URL = "https://civil-service-data-store-staging-aat.service.core-compute-aat.internal"
env.DM_STORE_URL = "http://dm-store-aat.service.core-compute-aat.internal"
env.AAC_API_URL="https://civil-service-manage-case-assignment-staging.aat.platform.hmcts.net"
yarnBuilder.yarn('yarn-update')
yarnBuilder.yarn('install-dependencies')
}
afterAlways('smoketest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'test-results/smokeTest/**/*'
}
afterAlways('functionalTest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'test-results/functional/**/*'
}
}