-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile_parameterized
134 lines (116 loc) · 4.54 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
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
@Library('Infrastructure')
def type = "java"
def product = "idam"
def component = "web-public"
def secrets = [
'idam-idam-${env}': [
secret('smoke-test-user-username', 'SMOKE_TEST_USER_USERNAME'),
secret('smoke-test-user-password', 'SMOKE_TEST_USER_PASSWORD'),
secret('notify-api-key', 'NOTIFY_API_KEY')
]
]
properties([
parameters([
choice(name: 'ENVIRONMENT', choices: 'idam-sandbox\npreview', description: 'Environment where code should be build and deployed'),
choice(name: 'SUBSCRIPTION', choices: 'sandbox\nnonprod', description: 'Azure subscriptions available to build in')
])
])
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
version : '',
envVariable: envVar
]
}
withParameterizedPipeline(type, product, component, params.ENVIRONMENT, params.SUBSCRIPTION){
loadVaultSecrets(secrets)
enableSlackNotifications('#idam_tech')
enableAksStagingDeployment()
disableLegacyDeployment()
// AKS Callbacks
before('akschartsinstall') {
env.PREVIEW_ENVIRONMENT_NAME = 'preview'
env.NONPROD_ENVIRONMENT_NAME = 'preview'
println """\
Using PREVIEW_ENVIRONMENT_NAME: ${env.PREVIEW_ENVIRONMENT_NAME}
Using NONPROD_ENVIRONMENT_NAME: ${env.NONPROD_ENVIRONMENT_NAME}""".stripIndent()
}
before('smoketest:idam-preview') {
env.PREVIEW_ENVIRONMENT_NAME = 'preview'
env.NONPROD_ENVIRONMENT_NAME = 'preview'
env.IDAMAPI = "https://idam-api.preview.platform.hmcts.net"
println """\
Using PREVIEW_ENVIRONMENT_NAME: ${env.PREVIEW_ENVIRONMENT_NAME}
Using NONPROD_ENVIRONMENT_NAME: ${env.NONPROD_ENVIRONMENT_NAME}
Using IDAMAPI: ${env.IDAMAPI}""".stripIndent()
}
before('functionalTest:idam-preview') {
env.PREVIEW_ENVIRONMENT_NAME = 'preview'
env.NONPROD_ENVIRONMENT_NAME = 'preview'
env.IDAMAPI = "https://idam-api.preview.platform.hmcts.net"
println """\
Using PREVIEW_ENVIRONMENT_NAME: ${env.PREVIEW_ENVIRONMENT_NAME}
Using NONPROD_ENVIRONMENT_NAME: ${env.NONPROD_ENVIRONMENT_NAME}
Using IDAMAPI: ${env.IDAMAPI}""".stripIndent()
}
afterAlways('akschartsinstall') {
env.PREVIEW_ENVIRONMENT_NAME = 'idam-preview'
env.NONPROD_ENVIRONMENT_NAME = 'idam-aat'
println """\
Using PREVIEW_ENVIRONMENT_NAME: ${env.PREVIEW_ENVIRONMENT_NAME}
Using NONPROD_ENVIRONMENT_NAME: ${env.NONPROD_ENVIRONMENT_NAME}""".stripIndent()
}
afterAlways('smoketest:idam-preview') {
env.PREVIEW_ENVIRONMENT_NAME = 'idam-preview'
env.NONPROD_ENVIRONMENT_NAME = 'idam-aat'
println """\
Using PREVIEW_ENVIRONMENT_NAME: ${env.PREVIEW_ENVIRONMENT_NAME}
Using NONPROD_ENVIRONMENT_NAME: ${env.NONPROD_ENVIRONMENT_NAME}""".stripIndent()
}
afterAlways('functionalTest:idam-preview') {
env.PREVIEW_ENVIRONMENT_NAME = 'idam-preview'
env.NONPROD_ENVIRONMENT_NAME = 'idam-aat'
println """\
Using PREVIEW_ENVIRONMENT_NAME: ${env.PREVIEW_ENVIRONMENT_NAME}
Using NONPROD_ENVIRONMENT_NAME: ${env.NONPROD_ENVIRONMENT_NAME}""".stripIndent()
}
// End AKS Callbacks
afterAlways('test') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/jacoco",
reportFiles : "index.html",
reportName : "IdAM Web Public Code Coverage Report"
]
}
afterAlways('smoketest:idam-preview') {
archiveArtifacts '**/build/test-results/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "output",
reportFiles : "idam-web-public-e2e-result.html",
reportName : "IDAM Web Public E2E smoke tests result"
]
}
afterAlways('functionalTest:idam-preview') {
archiveArtifacts '**/build/test-results/**/*'
archiveArtifacts '**/functional-output/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "output",
reportFiles : "idam-web-public-e2e-result.html",
reportName : "IDAM Web Public E2E functional tests result"
]
}
before('buildinfra:idam-prod') {
error('Stopping pipeline before Prod stages')
}
}