generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile_CNP
161 lines (143 loc) · 7 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
#!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 = "general-applications"
def camundaBranch = "master"
def generalappCCDBranch = "master"
def ccddefbranch = "master"
def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this)
AppPipelineConfig pipelineConf
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('generic-docker-pact-broker-password', 'GENERIC_DOCKER_PACT_BROKER_YAML_PASS'),
secret('default-password', 'DEFAULT_PASSWORD'),
secret('judge-default-password', 'JUDGE_DEFAULT_PASSWORD'),
secret('iac-default-password', 'IAC_DEFAULT_PASSWORD')
]
]
// 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, "enableHelm").contains("enableHelm")
}
withPipeline(type, product, component) {
pipelineConf = config
disableLegacyDeployment()
enableAksStagingDeployment()
onPR {
enablePactAs([AppPipelineDsl.PactRoles.CONSUMER])
env.ENVIRONMENT = "preview"
env.YARN_ENABLE_IMMUTABLE_INSTALLS = false
loadVaultSecrets(secrets)
}
onMaster {
enablePactAs([AppPipelineDsl.PactRoles.CONSUMER])
env.ENVIRONMENT = "aat"
env.YARN_ENABLE_IMMUTABLE_INSTALLS = false
loadVaultSecrets(secrets)
}
onDemo {
env.YARN_ENABLE_IMMUTABLE_INSTALLS = false
env.ENVIRONMENT = "demo"
loadVaultSecrets(secrets)
}
before('smoketest:preview') {
retry(3) {
env.IDAM_API_URL = "https://idam-api.aat.platform.hmcts.net"
env.URL = "https://xui-civil-general-applications-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.CIVIL_GENERAL_APPLICATIONS_URL = "https://civil-general-applications-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.CIVIL_SERVICE_URL = "https://civil-service-civil-general-applications-pr-${CHANGE_ID}.preview.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-general-applications-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.DM_STORE_URL = "http://dm-store-aat.service.core-compute-aat.internal"
env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
sh """
eval \$(./bin/variables/load-preview-environment-variables.sh ${CHANGE_ID})
./bin/wait-for.sh definition-store
./bin/add-roles.sh
./bin/pull-latest-general-app-ccd-files.sh ${generalappCCDBranch}
./bin/import-ccd-definition.sh "-e *-prod.json,*HNL-nonprod.json,*-shuttered.json" ${ccddefbranch}
./bin/import-general-apps-ccd-definition.sh "-e *-prod.json"
./bin/pull-latest-camunda-files.sh ${camundaBranch}
"""
}
yarnBuilder.yarn('yarn-update')
yarnBuilder.yarn('install-dependencies')
}
afterAlways('smoketest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'test-results/smokeTest/**/*'
}
before('functionalTest:preview') {
env.IDAM_API_URL = "https://idam-api.aat.platform.hmcts.net"
env.URL = "https://xui-civil-general-applications-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.CIVIL_GENERAL_APPLICATIONS_URL = "https://civil-general-applications-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.CIVIL_SERVICE_URL = "https://civil-service-civil-general-applications-pr-${CHANGE_ID}.preview.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-general-applications-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.DM_STORE_URL = "http://dm-store-aat.service.core-compute-aat.internal"
}
afterAlways('functionalTest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'test-results/functional/**/*'
}
afterAlways('functionalTest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'test-results/functional/**/*'
}
before('smoketest:aat') {
retry(3) {
env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
env.URL = "https://civil-ga-xui-staging.aat.platform.hmcts.net"
env.CIVIL_GENERAL_APPLICATIONS_URL = "https://civil-general-applications-staging.aat.platform.hmcts.net"
env.CIVIL_SERVICE_URL = "https://civil-ga-civil-service-staging.aat.platform.hmcts.net"
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-ga-data-store-staging.aat.platform.hmcts.net"
env.DM_STORE_URL = "https://dm-store-aat.service.core-compute-aat.internal"
sh """
eval \$(./bin/variables/load-staging-environment-variables.sh)
./bin/wait-for.sh definition-store
./bin/add-roles.sh
./bin/pull-latest-general-app-ccd-files.sh ${generalappCCDBranch}
./bin/import-ccd-definition.sh "-e *-prod.json,*HNL-nonprod.json,*-shuttered.json" ${ccddefbranch}
./bin/import-general-apps-ccd-definition.sh "-e *-prod.json"
./bin/pull-latest-camunda-files.sh ${camundaBranch}
"""
}
yarnBuilder.yarn('yarn-update')
yarnBuilder.yarn('install-dependencies')
}
afterAlways('smoketest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'test-results/smokeTest/**/*'
}
}