forked from hmcts/ccd-elastic-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_parameterized
47 lines (41 loc) · 1.64 KB
/
Jenkinsfile_parameterized
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
#!groovy
@Library("Infrastructure") _
import uk.gov.hmcts.contino.HealthChecker
import uk.gov.hmcts.contino.azure.KeyVault
properties([
parameters([
string(name: 'PRODUCT_NAME', defaultValue: 'ccd-elastic-search', description: ''),
choice(name: 'ENVIRONMENT', choices: 'sandbox\nsaat\nsprod', description: 'Environment where code should be build and deployed')
])
])
withParameterizedInfraPipeline(params.PRODUCT_NAME, params.ENVIRONMENT, 'sandbox') {
afterAlways('buildinfra:sandbox') {
echo 'Healthcheck in Sandbox'
healthCheckStage('sandbox', 'sandbox')
}
afterAlways('buildinfra:saat') {
echo 'Healthcheck in SAAT'
healthCheckStage('sandbox', 'saat')
}
afterAlways('buildinfra:sandbox') {
echo 'Healthcheck in sprod'
healthCheckStage('sandbox', 'sprod')
}
}
def healthCheckStage(subscription, environmentName) {
stage('HealthCheck') {
def healthChecker = new HealthChecker(this)
healthChecker.check(healthCheckUrl(subscription, environmentName), 10, 40) { response ->
if (response.content.contains("yellow")) {
currentBuild.result = "UNSTABLE"
}
!response.content.contains("red")
}
}
}
def healthCheckUrl(subscription, environmentName) {
KeyVault keyVault = new KeyVault(this, subscription, "ccd-$environmentName")
es_url = keyVault.find("ccd-ELASTIC-SEARCH-URL").trim()
echo "retrieved ES URL: ${es_url}"
"http://" + es_url + ":9200/_cluster/health"
}