forked from hmcts/document-management-store-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_parameterized
208 lines (188 loc) · 6.98 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!groovy
properties([
[
$class: 'GithubProjectProperty',
displayName: 'Document Management Store App',
projectUrlStr: 'https://github.com/hmcts/document-management-store-app'
],
parameters([
booleanParam(
defaultValue: false,
description: 'Run Performance',
name: 'RUN_PT'
),
choice(
name: 'ENVIRONMENT',
choices: 'saat\nsprod\nsandbox',
description: 'Environment where code should be build and deployed')
]),
pipelineTriggers([
[$class: 'GitHubPushTrigger']
])
])
@Library("Infrastructure")
def type = "java"
def product = "dm"
def component = "store"
def secrets = [
's2s-${env}': [
secret('microservicekey-em-gw', 'S2S_TOKEN'),
secret('microservicekey-ccd-case-disposer', 'CCD_CASE_DISPOSER_S2S_TOKEN')
],
'dm-${env}': [
secret('dm-store-storage-account-primary-connection-string', 'STORAGEACCOUNT_PRIMARY_CONNECTION_STRING')
]
]
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[ $class: 'AzureKeyVaultSecret',
secretType: 'Secret',
name: secretName,
version: '',
envVariable: envVar
]
}
def vaultOverrides = [
'preview': 'aat',
'spreview': 'saat'
]
withParameterizedPipeline(type, product, component, params.ENVIRONMENT, 'sandbox') {
enableSlackNotifications('#ccd-param-builds')
enableDbMigration('dm')
overrideVaultEnvironments(vaultOverrides)
loadVaultSecrets(secrets)
afterSuccess('checkout') {
echo '${product}-${component} out'
sh '''
mkdir -p application/src/main/resources/META-INF
echo "allprojects { task printVersionInit { doLast { println project.version } } }" > init.gradle
tee application/src/main/resources/META-INF/build-info.properties <<EOF 2>/dev/null
build.version=$(./gradlew -q printVersion)
build.number=${BUILD_NUMBER}
build.commit=$(git rev-parse HEAD)
build.date=$(date)
EOF
'''
}
afterAlways('test'){
junit 'application/build/test-results/test/**/*.xml'
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "application/build/reports/tests/test/",
reportFiles : 'index.html',
reportName : 'Unit Test Report'
])
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "application/build/reports/checkstyle/",
reportFiles : 'main.html',
reportName : 'Checkstyle Main Report'
])
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "application/build/reports/checkstyle/",
reportFiles : 'test.html',
reportName : 'Checkstyle Test Report'
])
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "application/build/reports/pmd/",
reportFiles : 'main.html',
reportName : 'PMD Main Report'
])
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "application/build/reports/pmd/",
reportFiles : 'test.html',
reportName : 'PMD Test Report'
])
try {
sh './gradlew jacocoTestReport --info'
}finally {
jacoco(execPattern: 'application/build/jacoco/test.exec', buildOverBuild: false,
exclusionPattern: '**/test/*, ' +
'**/uk/gov/hmcts/dm/DmApp.java,'+
'**/uk/gov/hmcts/dm/hateos/*,'+
'**/uk/gov/hmcts/dm/exception/*,'+
'**/uk/gov/hmcts/dm/domain/*,'+
'**/uk/gov/hmcts/dm/commandobject/*,'+
'**/uk/gov/hmcts/dm/hibernate/*,'+
'**/uk/gov/hmcts/dm/config/**/*,'+
'**/uk/gov/hmcts/dm/errorhandler/*,'+
'**/uk/gov/hmcts/dm/repository/RepositoryFinder.java')
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "application/build/reports/jacoco/test/html/",
reportFiles : 'index.html',
reportName : 'Jacoco Coverage Report'
])
}
}
afterAlways('smoketest:spreview') {
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "smokeTests/build/reports/tests/smoke/",
reportFiles : 'index.html',
reportName : 'SPREVIEW Smoke Test'
])
}
afterAlways('functionalTest:spreview') {
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "functionalTests/build/reports/tests/functional/",
reportFiles : 'index.html',
reportName : 'SPREVIEW Functional Test'
])
}
afterAlways('smoketest:saat') {
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "smokeTests/build/reports/tests/smoke/",
reportFiles : 'index.html',
reportName : 'SAAT Smoke Test'
])
}
afterAlways('functionalTest:saat') {
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "functionalTests/build/reports/tests/functional/",
reportFiles : 'index.html',
reportName : 'SAAT Functional Test'
])
}
afterAlways('smoketest:sprod'){
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "smokeTests/build/reports/tests/smoke/",
reportFiles : 'index.html',
reportName : 'SPROD Smoke Test'
])
}
afterAlways('functionalTest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/site/serenity/**/*'
}
afterAlways('functionalTest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/site/serenity/**/*'
}
}