This repository has been archived by the owner on May 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile_CNP
160 lines (139 loc) · 5.37 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
#!groovy
@Library("Infrastructure")
import uk.gov.hmcts.contino.AppPipelineConfig
def type = "java"
def product = "civil-damages"
def component = "camunda"
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 createGithubRelease() {
sh """
./bin/create-github-release.sh
"""
}
def uploadBpmnDiagrams(String env) {
dir("${WORKSPACE}/bin") {
sh """
eval \$(./variables/load-${env}-environment-variables.sh)
./import-bpmn-diagram.sh ${WORKSPACE}
"""
}
}
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: 'civil-damages-camunda-bpmn-definition: failed to update demo branch'
}
}
}
onDemo {
def subscription = 'nonprod'
withSubscription(subscription) {
withTeamSecrets(pipelineConf, 'demo') {
uploadBpmnDiagrams('demo')
}
}
}
}
before('smoketest:preview') {
sh """
eval \$(./bin/variables/load-preview-environment-variables.sh ${CHANGE_ID})
./bin/add-roles.sh
./bin/pull-latest-release-asset.sh civil-damages-ccd-definition civil-damages-ccd-definition.zip
./bin/pull-latest-release-asset.sh civil-damages-ccd-definition civil-damages-e2e.zip
./bin/import-ccd-definition.sh
"""
env.URL="https://xui-civil-damages-camunda-pr-${CHANGE_ID}.service.core-compute-preview.internal"
env.UNSPEC_SERVICE_URL="http://civil-damages-camunda-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-civil-damages-camunda-pr-${CHANGE_ID}.service.core-compute-preview.internal"
env.DM_STORE_URL = "http://dm-store-aat.service.core-compute-aat.internal"
env.UNSPEC_SERVICE_URL="http://civil-damages-camunda-pr-${CHANGE_ID}.service.core-compute-preview.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') {
sh """
eval \$(./bin/variables/load-staging-environment-variables.sh)
./bin/add-roles.sh
./bin/pull-latest-release-asset.sh civil-damages-ccd-definition civil-damages-ccd-definition.zip
./bin/pull-latest-release-asset.sh civil-damages-ccd-definition civil-damages-e2e.zip
./bin/import-ccd-definition.sh
"""
env.URL="https://civil-damages-camunda-xui-staging.aat.platform.hmcts.net"
env.UNSPEC_SERVICE_URL="http://civil-damages-camunda-staging.service.core-compute-aat.internal"
}
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://civil-damages-camunda-data-store-staging-aat.service.core-compute-aat.internal"
env.DM_STORE_URL = "http://dm-store-aat.service.core-compute-aat.internal"
env.UNSPEC_SERVICE_URL="http://civil-damages-camunda-staging.service.core-compute-aat.internal"
uploadBpmnDiagrams('staging')
}
after('functionalTest:aat') {
createGithubRelease()
uploadBpmnDiagrams('aat')
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'output/**/*'
}
}