generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile_CNP
190 lines (165 loc) · 7.31 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
186
187
188
189
190
#!groovy
@Library("Infrastructure")
import uk.gov.hmcts.contino.GradleBuilder
import uk.gov.hmcts.contino.GithubAPI
def type = "java"
def product = "darts"
def component = "api"
def branchesToSync = ['demo', 'perftest', 'ithc']
def secrets = [
'darts-${env}': [
secret('GovukNotifyTestApiKey', 'GOVUK_NOTIFY_API_KEY'),
secret('app-insights-connection-string', 'app-insights-connection-string'),
secret('AzureAdB2CTenantId', 'AAD_B2C_TENANT_ID'),
secret('AzureAdB2CClientId', 'AAD_B2C_CLIENT_ID'),
secret('AzureAdB2CClientSecret', 'AAD_B2C_CLIENT_SECRET'),
secret('AzureAdB2CFuncTestROPCUsername', 'FUNC_TEST_ROPC_USERNAME'),
secret('AzureAdB2CFuncTestROPCPassword', 'FUNC_TEST_ROPC_PASSWORD'),
secret('AzureAdB2CFuncTestROPCClientId', 'AAD_B2C_ROPC_CLIENT_ID'),
secret('AzureAdB2CFuncTestROPCClientSecret', 'AAD_B2C_ROPC_CLIENT_SECRET'),
secret('api-POSTGRES-SCHEMA', 'DARTS_API_DB_SCHEMA'),
secret('AzureStorageConnectionString', 'AZURE_STORAGE_CONNECTION_STRING'),
secret('AzureADTenantId', 'AAD_TENANT_ID'),
secret('AzureADClientId', 'AAD_CLIENT_ID'),
secret('AzureADClientSecret', 'AAD_CLIENT_SECRET'),
secret('AzureADTenantIdJustice', 'AAD_TENANT_ID_JUSTICE'),
secret('AzureADClientIdJustice', 'AAD_CLIENT_ID_JUSTICE'),
secret('AzureADClientSecretJustice', 'AAD_CLIENT_SECRET_JUSTICE'),
secret('XhibitUserName', 'XHIBIT_USER_NAME'),
secret('XhibitPassword', 'XHIBIT_PASSWORD'),
secret('CppUserName', 'CPP_USER_NAME'),
secret('CppPassword', 'CPP_PASSWORD'),
secret('DarPcUserName', 'DARPC_USER_NAME'),
secret('DarPcPassword', 'DARPC_PASSWORD'),
secret('DarMidTierUserName', 'DAR_MIDTIER_USER_NAME'),
secret('DarMidTierPassword', 'DAR_MIDTIER_PASSWORD'),
secret('AzureADFunctionalTestUsername', 'AZURE_AD_FUNCTIONAL_TEST_USERNAME'),
secret('AzureADFunctionalTestPassword', 'AZURE_AD_FUNCTIONAL_TEST_PASSWORD'),
secret('DartsSystemUserEmail', 'SYSTEM_USER_EMAIL'),
secret('AzureAdB2CFuncTestROPCGlobalUsername', 'AZURE_AD_FUNCTIONAL_TEST_GLOBAL_USERNAME'),
secret('AzureAdB2CFuncTestROPCGlobalPassword', 'AZURE_AD_FUNCTIONAL_TEST_GLOBAL_PASSWORD'),
secret('ARMSasEndpoint', 'ARM_SAS_ENDPOINT'),
secret('DETSSasURLEndpoint', 'DETS_SAS_URL_ENDPOINT'),
secret('DartsInboundStorageSasUrl', 'DARTS_INBOUND_STORAGE_SAS_URL'),
secret('DartsUnstructuredStorageSasUrl', 'DARTS_UNSTRUCTURED_STORAGE_SAS_URL'),
secret('ArmServiceEntitlement', 'ARM_SERVICE_ENTITLEMENT'),
secret('ArmStorageAccountName', 'ARM_STORAGE_ACCOUNT_NAME'),
// secrets for staging DB
secret('api-POSTGRES-HOST', 'STAGING_DB_HOST'),
secret('api-POSTGRES-USER', 'STAGING_DB_USER'),
secret('api-POSTGRES-PASS', 'STAGING_DB_PASS'),
secret('api-POSTGRES-PORT', 'STAGING_DB_PORT'),
secret('api-POSTGRES-SCHEMA', 'STAGING_DB_SCHEMA'),
secret('api-POSTGRES-DATABASE', 'STAGING_DB_DATABASE'),
],
]
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
version : '',
envVariable: envVar
]
}
def determineDevEnvironmentDeployment() {
env.DEV_ENABLE_DARTS_PORTAL = false
env.DEV_DARTS_PORTAL_URL = "https://darts.staging.apps.hmcts.net"
echo "1 - env.DEV_ENABLE_DARTS_PORTAL: ${env.DEV_ENABLE_DARTS_PORTAL}"
echo "1 - env.DEV_DARTS_PORTAL_URL: ${env.DEV_DARTS_PORTAL_URL}"
def githubApi = new GithubAPI(this)
if (githubApi.checkForLabel(env.BRANCH_NAME, "enable_keep_helm")) {
for (label in githubApi.getLabelsbyPattern(env.BRANCH_NAME, "enable_darts_") ) {
if (label == "enable_darts_portal") {
env.DEV_ENABLE_DARTS_PORTAL = true
env.DEV_DARTS_PORTAL_URL = "https://darts-portal-pr-${env.CHANGE_ID}.dev.platform.hmcts.net"
echo "Deploying DARTS portal instance in PR environment"
}
}
}
echo "2 - env.DEV_ENABLE_DARTS_PORTAL: ${env.DEV_ENABLE_DARTS_PORTAL}"
echo "2 - env.DEV_DARTS_PORTAL_URL: ${env.DEV_DARTS_PORTAL_URL}"
}
GradleBuilder builder = new GradleBuilder(this, product)
withPipeline(type, product, component) {
enableDbMigration(product)
loadVaultSecrets(secrets)
enableSlackNotifications('#darts-builds')
syncBranchesWithMaster(branchesToSync)
disableCleanupOfHelmReleaseOnFailure()
afterAlways('test') {
builder.gradle('jacocoTestReport')
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/checkstyle",
reportFiles : "main.html",
reportName : "Checkstyle Main Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/checkstyle",
reportFiles : "test.html",
reportName : "Checkstyle Test Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/checkstyle",
reportFiles : "functionalTest.html",
reportName : "Checkstyle Functional Test Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/checkstyle",
reportFiles : "integrationTest.html",
reportName : "Checkstyle Integration Test Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/test",
reportFiles : "index.html",
reportName : "Unit Tests Report"
]
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/pmd",
reportFiles : "main.html",
reportName : "PMD Report"
]
}
afterFailure('test') {
junit '**/test-results/integration/*.xml'
}
before('dbmigrate:demo') {
sh("./gradlew --no-daemon --init-script init.gradle assemble")
}
before('dbmigrate:test') {
sh("./gradlew --no-daemon --init-script init.gradle assemble")
}
before('dbmigrate:ithc') {
sh("./gradlew --no-daemon --init-script init.gradle assemble")
}
before('akschartsinstall') {
onPR {
determineDevEnvironmentDeployment()
}
}
afterSuccess('akschartsinstall') {
onPR {
// restore the PR DB from staging
sh("./bin/ci/db-stg-to-pr.sh")
// run flyway migrate on PR DB
sh("./bin/ci/run-flyway-pr-db.sh")
}
}
}