forked from hmcts/sscs-tribunals-case-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_CNP
135 lines (121 loc) · 6.61 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
#!groovy
properties([
[$class: 'GithubProjectProperty', projectUrlStr: 'https://github.com/hmcts/tribunals-case-api'],
pipelineTriggers([[$class: 'GitHubPushTrigger']])
])
@Library("Infrastructure")
import uk.gov.hmcts.contino.AppPipelineDsl
import uk.gov.hmcts.contino.GithubAPI
import uk.gov.hmcts.contino.GradleBuilder
def type = "java"
def product = "sscs"
def component = "tribunals-api"
def gradleBuilder = new GradleBuilder(this, product)
def secrets = [
'sscs-${env}' : [
secret('idam-api', 'IDAM_API_URL'),
secret('idam-oauth-user', 'IDAM_OAUTH2_CLIENT_ID'),
secret('ccd-api', 'CORE_CASE_DATA_API_URL'),
secret('idam-redirect', 'IDAM_OAUTH2_REDIRECT_URL'),
secret('idam-sscs-systemupdate-user', 'IDAM_SSCS_SYSTEMUPDATE_USER'),
secret('idam-sscs-systemupdate-password', 'IDAM_SSCS_SYSTEMUPDATE_PASSWORD'),
secret('idam-sscs-oauth2-client-secret', 'IDAM_OAUTH2_CLIENT_SECRET'),
secret('idam-s2s-api', 'IDAM_S2S_AUTH'),
secret('sscs-s2s-secret', 'IDAM_S2S_AUTH_TOTP_SECRET'),
secret('s2s-micro', 'IDAM_S2S_AUTH_MICROSERVICE'),
secret('docmosis-endpoint', 'PDF_SERVICE_CONVERT_URL'),
secret('docmosis-api-key', 'PDF_SERVICE_ACCESS_KEY'),
secret('AppInsightsInstrumentationKey', 'APPINSIGHTS_INSTRUMENTATIONKEY'),
],
'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'),
secret('ccd-admin-web-oauth2-client-secret', 'ADMIN_WEB_IDAM_SECRET')
]
]
def secretsForPR = [
'sscs-${env}' : [
secret('idam-api', 'IDAM_API_URL'),
secret('idam-oauth-user', 'IDAM_OAUTH2_CLIENT_ID'),
secret('idam-redirect', 'IDAM_OAUTH2_REDIRECT_URL'),
secret('idam-sscs-systemupdate-user', 'IDAM_SSCS_SYSTEMUPDATE_USER'),
secret('idam-sscs-systemupdate-password', 'IDAM_SSCS_SYSTEMUPDATE_PASSWORD'),
secret('idam-sscs-oauth2-client-secret', 'IDAM_OAUTH2_CLIENT_SECRET'),
secret('idam-s2s-api', 'IDAM_S2S_AUTH'),
secret('sscs-s2s-secret', 'IDAM_S2S_AUTH_TOTP_SECRET'),
secret('s2s-micro', 'IDAM_S2S_AUTH_MICROSERVICE'),
secret('docmosis-endpoint', 'PDF_SERVICE_CONVERT_URL'),
secret('docmosis-api-key', 'PDF_SERVICE_ACCESS_KEY'),
secret('AppInsightsInstrumentationKey', 'APPINSIGHTS_INSTRUMENTATIONKEY'),
],
'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'),
secret('ccd-admin-web-oauth2-client-secret', 'ADMIN_WEB_IDAM_SECRET'),
secret('idam-data-store-system-user-password', 'IDAM_DATA_STORE_SYSTEM_USER_PASSWORD'),
secret('idam-data-store-system-user-username', 'IDAM_DATA_STORE_SYSTEM_USER_USERNAME'),
secret('idam-data-store-client-secret', 'IDAM_OAUTH2_DATA_STORE_CLIENT_SECRET')
]
]
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[ $class: 'AzureKeyVaultSecret',
secretType: 'Secret',
name: secretName,
version: '',
envVariable: envVar
]
}
def branchesToSync = ['demo', 'ithc', 'perftest']
withPipeline(type, product, component) {
if (env.BRANCH_NAME.startsWith("PR")) {
loadVaultSecrets(secretsForPR)
} else {
loadVaultSecrets(secrets)
}
enableSlackNotifications('#sscs-tech')
enableAksStagingDeployment()
disableLegacyDeployment()
syncBranchesWithMaster(branchesToSync)
before('akschartsinstall'){
def sscsCommonVersion = sh(script: './gradlew -q getSscsCommonVersion', returnStdout: true).trim()
def languages = sh(script: "curl https://raw.githubusercontent.com/hmcts/sscs-common/${sscsCommonVersion}/src/main/resources/reference-data/languages.txt", returnStdout: true)
env.CCD_DEF_LANGUAGES = "'${languages}'"
def pipQues = sh(script: "curl https://raw.githubusercontent.com/hmcts/sscs-common/${sscsCommonVersion}/src/main/resources/reference-data/pip-decision-notice-questions.txt", returnStdout: true)
env.PIP_DECISION_NOTICE_QUESTIONS = "'${pipQues}'"
def esaQues = sh(script: "curl https://raw.githubusercontent.com/hmcts/sscs-common/${sscsCommonVersion}/src/main/resources/reference-data/esa-decision-notice-questions.txt", returnStdout: true)
env.ESA_DECISION_NOTICE_QUESTIONS = "'${esaQues}'"
def ucQues = sh(script: "curl https://raw.githubusercontent.com/hmcts/sscs-common/${sscsCommonVersion}/src/main/resources/reference-data/uc-decision-notice-questions.txt", returnStdout: true)
env.UC_DECISION_NOTICE_QUESTIONS = "'${ucQues}'"
}
after('akschartsinstall'){
// Vars needed for AKS testing
env.TEST_DOCUMENT_MANAGEMENT_URL = 'http://dm-store-aat.service.core-compute-aat.internal'
env.CORE_CASE_DATA_API_URL = "http://ccd-data-store-api-aat.service.core-compute-aat.internal"
if (env.BRANCH_NAME.startsWith("PR")) {
def githubApi = new GithubAPI(this)
for (label in githubApi.getLabelsbyPattern(env.BRANCH_NAME, "pr-values:ccd") ) {
env.CORE_CASE_DATA_API_URL = "ccd-data-store-api-sscs-tribunals-api-pr-${CHANGE_ID}.service.core-compute-preview.internal"
println """After akschartsinstall Using CORE_CASE_DATA_API_URL: ${env.CORE_CASE_DATA_API_URL}""".stripIndent()
}
}
println """After akschartsinstall Using CORE_CASE_DATA_API_URL: ${env.CORE_CASE_DATA_API_URL}. - The branch name is ${env.BRANCH_NAME}""".stripIndent()
}
env.PACT_BROKER_FULL_URL = 'https://pact-broker.platform.hmcts.net'
onMaster() {
enablePactAs([AppPipelineDsl.PactRoles.CONSUMER])
}
onPR() {
enablePactAs([AppPipelineDsl.PactRoles.CONSUMER,
AppPipelineDsl.PactRoles.CONSUMER_DEPLOY_CHECK])
}
}