This repository has been archived by the owner on Apr 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile_CNP
185 lines (159 loc) · 5.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!groovy
@Library("Infrastructure")
import uk.gov.hmcts.contino.AppPipelineConfig
def type = "java"
def product = "unspec"
def component = "service"
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('postcode-info-address-lookup-token', 'ADDRESS_LOOKUP_TOKEN')
],
'unspec-${env}': [
secret('microservicekey-unspec-service', 'S2S_SECRET'),
secret('ccd-importer-username', 'CCD_CONFIGURER_IMPORTER_USERNAME'),
secret('ccd-importer-password', 'CCD_CONFIGURER_IMPORTER_PASSWORD')
]
]
def archiveCoreCaseDataDefinitions(env) {
dir("${WORKSPACE}/bin") {
sh "./build-release-ccd-definition.sh ${env}"
}
dir("${WORKSPACE}/build") {
steps.archiveArtifacts artifacts: "ccd-release-config/ccd-unspec-${env}.xlsx"
}
}
def uploadCoreCaseDataDefinitions(env) {
dir("${WORKSPACE}/bin"){
ccdDefinitionFilePath="${WORKSPACE}/build/ccd-release-config/ccd-unspec-${env}.xlsx"
sh """
eval \$(./variables/load-${env}-environment-variables.sh)
${WORKSPACE}/civil-unspecified-docker/bin/utils/ccd-import-definition.sh ${ccdDefinitionFilePath}
"""
}
}
def uploadBpmnDiagrams(String env) {
dir("${WORKSPACE}/bin") {
sh """
eval \$(./variables/load-${env}-environment-variables.sh)
./import-bpmn-diagram.sh ${WORKSPACE}
"""
}
}
def validateRpaContract() {
sh """ ./gradlew contract """
}
def publishRpaContract() {
env.PACT_BROKER_FULL_URL="https://pact-broker.platform.hmcts.net/"
sh """ ./gradlew pactPublish """
}
withPipeline(type, product, component) {
pipelineConf = config
disableLegacyDeployment()
enableAksStagingDeployment()
enableSlackNotifications('#unspec_notification')
onPR {
loadVaultSecrets(secrets)
}
onMaster {
loadVaultSecrets(secrets)
}
onDemo {
loadVaultSecrets(secrets)
}
after('checkout') {
onMaster {
withCredentials([usernamePassword(credentialsId: 'jenkins-github-hmcts-api-token', usernameVariable: 'USERNAME', passwordVariable: 'BEARER_TOKEN')]) {
try {
sh '''
set -e
git remote set-url origin $(git config remote.origin.url | sed "s/github.com/${BEARER_TOKEN}@github.com/g")
git fetch origin demo:demo
git push --force origin HEAD:demo
'''
} catch (err) {
notifyBuildEvent channel: '#unspec_notification', color: 'warning', message: 'Failed to update demo branch'
}
}
}
sh """ git submodule update --init """
}
before('smoketest:preview') {
validateRpaContract()
sh """
eval \$(./bin/variables/load-preview-environment-variables.sh ${CHANGE_ID})
./bin/add-roles-preview.sh
./bin/import-ccd-definition.sh
"""
env.URL="https://xui-unspec-service-pr-${CHANGE_ID}.service.core-compute-preview.internal"
env.UNSPEC_SERVICE_URL="http://unspec-service-pr-${CHANGE_ID}.service.core-compute-preview.internal"
}
after('smoketest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'output/**/*'
}
before('functionalTest:preview') {
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 = "http://ccd-data-store-api-unspec-service-pr-${CHANGE_ID}.service.core-compute-preview.internal"
env.DM_STORE_URL = "http://dm-store-aat.service.core-compute-aat.internal"
dir("${WORKSPACE}/bin") {
sh """
eval \$(./variables/load-preview-environment-variables.sh ${CHANGE_ID})
./import-bpmn-diagram.sh ${WORKSPACE}
"""
}
}
after('functionalTest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'output/**/*'
}
before('smoketest:aat') {
validateRpaContract()
env.URL = "https://manage-case.aat.platform.hmcts.net"
env.UNSPEC_SERVICE_URL="http://unspec-service-staging.service.core-compute-aat.internal"
archiveCoreCaseDataDefinitions('staging')
}
after('smoketest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'output/**/*'
}
before('functionalTest:aat') {
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 = "http://ccd-data-store-api-aat.service.core-compute-aat.internal"
env.DM_STORE_URL = "http://dm-store-aat.service.core-compute-aat.internal"
}
after('functionalTest:aat') {
env.URL = "https://manage-case.aat.platform.hmcts.net"
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'output/**/*'
archiveCoreCaseDataDefinitions('aat')
}
before('buildinfra:demo') {
def subscription = 'nonprod'
withSubscription(subscription) {
withTeamSecrets(pipelineConf, 'demo') {
archiveCoreCaseDataDefinitions('demo')
dir("${WORKSPACE}/bin") {
sh """
./wait-for.sh https://manage-case.demo.platform.hmcts.net
./wait-for.sh http://unspec-service-demo.service.core-compute-demo.internal
"""
}
}
}
}
after('smoketest:demo') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'output/**/*'
}
}