-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathJenkinsfile.nightly
221 lines (210 loc) · 9.49 KB
/
Jenkinsfile.nightly
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
209
210
211
212
213
214
215
216
217
218
219
220
221
def branchName = null
def jobName = null
def productsBuild = null
def outputDir = 'test-result'
def artifactFilterRcptt = 'gui-test-runner/result/**/*'
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '500'))
}
triggers {
pollSCM 'H 1 * * 1-5'
}
stages {
stage('Build products') {
steps {
sh "rm -r -f ${WORKSPACE}/${outputDir}"
script {
branchName = env.GIT_BRANCH.replace('origin/', '')
jobName = "verinice/${branchName.replace('/', '%2F')}"
productsBuild = build(
job: jobName,
propagate: false,
parameters: [
booleanParam(name: 'runRCPTTTests', value: false),
booleanParam(name: 'archiveIntegrationTestResults', value: true),
booleanParam(name: 'generateSNCAReport', value: true)
]
)
copyArtifacts(
filter: '**/build/reports/**/*.xml,**/target/surefire-reports/*.xml',
projectName: jobName,
selector: specific(productsBuild.getNumber().toString()),
target: "${outputDir}/integration"
)
}
}
}
stage('Run UI tests') {
parallel {
stage('Run UI tests on Linux') {
steps {
runRCPTT 'rcptt-client-test', branchName, jobName, productsBuild.number, 'Linux', artifactFilterRcptt, "${outputDir}/gui-test-linux", 'GUI Test Report (Linux)', 'linux-verince-client-log'
}
}
stage('Run UI tests on macOS Current') {
steps {
runRCPTT 'rcptt-client-test', branchName, jobName, productsBuild.number, 'macOS current', artifactFilterRcptt, "${outputDir}/gui-test-mac-current", 'GUI Test Report (macOS)', 'macc-verince-client-log'
}
}
stage('Run UI tests on Windows') {
steps {
runRCPTT 'rcptt-client-test', branchName, jobName, productsBuild.number, 'Windows 10', artifactFilterRcptt, "${outputDir}/gui-test-windows", 'GUI Test Report (Windows 10)', 'win-verince-client-log'
}
}
stage('Run 3-tier UI tests') {
steps {
runRCPTT 'rcptt-server-test', branchName, jobName, productsBuild.number, null, artifactFilterRcptt, "${outputDir}/gui-test-3-tier", 'GUI Test Report (3-tier)', '3-tier-verince-client-log'
recordLogMessages '3-tier-verince-server-log', "${outputDir}/gui-test-3-tier", 'verinice-server.*', 'serverlogparsed-nighly.txt', 'log4j'
}
}
stage('Run reporting tests') {
steps {
script {
def target = "${outputDir}/reporting-all"
runRCPTT 'rcptt-all-report-tests', branchName, jobName, productsBuild.number, null, 'test-result/**/*', target, null, null
archiveArtifacts artifacts: "${target}/**/*"
// FIXME enable again when VN-2882 is done
// createPerformancePlot("${target}/test-result/products_de/metric.csv", 'Product Reports')
createPerformancePlot("${target}/test-result/vn_de/metric.csv", 'Verinice Reports (DE)')
createPerformancePlot("${target}/test-result/vn_en/metric.csv", 'Verinice Reports (EN)')
}
}
}
stage('Run standalone performance tests') {
steps {
script {
def target = "${outputDir}/performance-test-standalone"
runRCPTT 'rcptt-client-performance-test', branchName, jobName, productsBuild.number, null, artifactFilterRcptt, target, 'GUI Test Report (Performance Standalone)', 'performance-verince-client-log'
createPerformancePlot("${target}/gui-test-runner/result/metric.csv", 'Standalone')
}
}
}
stage('Run 3-tier performance tests') {
steps {
script {
def target = "${outputDir}/performance-test-3-tier"
runRCPTT 'rcptt-server-performance-test', branchName, jobName, productsBuild.number, null, artifactFilterRcptt, target, 'GUI Test Report (Performance 3-tier)','3-tier-performance-verince-client-log'
recordLogMessages '3-tier-performance-verince-server-log', "${outputDir}/performance-test-3-tier", 'verinice-server.*', 'serverlogparsed-nighly.txt', 'log4j'
createPerformancePlot("${target}/gui-test-runner/result/metric.csv", '3-tier')
}
}
}
}
}
stage('Record results') {
steps {
// archiveArtifacts artifacts: "${outputDir}/**/*.xml"
junit(
allowEmptyResults: true,
testDataPublishers: [[$class: 'StabilityTestDataPublisher']],
testResults: "${outputDir}/**/*.xml"
)
perfReport(
filterRegex: '',
modePerformancePerTestCase: true,
sourceDataFiles: "${outputDir}/**/*.xml"
)
}
}
}
post {
failure {
emailext to: '[email protected], [email protected]',
body: '''The build is broken.
Take a look.
${BUILD_LOG_REGEX}
${FAILED_TESTS}
${CHANGES_SINCE_LAST_SUCCESS}
${JELLY_SCRIPT,template="text"}''',
subject: '$DEFAULT_SUBJECT'
}
unstable {
emailext to: '[email protected], [email protected]',
body: '''The build is unstable.
Take a look.
${FAILED_TESTS}
${CHANGES_SINCE_LAST_SUCCESS}
${JELLY_SCRIPT,template="text"}''',
subject: '$DEFAULT_SUBJECT'
}
}
}
def runRCPTT(jobName, branchName, jobNameArtifacts, buildNumberArtifacts, operatingSystem, copyArtifactsFilter, resultDir, htmlReportName, logMessageTrendName){
def rcpttBuild = build(
job: jobName,
propagate: false,
parameters: [
gitParameter(name: 'BRANCH_OR_TAG', value: branchName),
string(name: 'job_to_copy_from', value: jobNameArtifacts),
string(name: 'build_to_copy_from', value: """<SpecificBuildSelector plugin="[email protected]"> <buildNumber>${buildNumberArtifacts}</buildNumber></SpecificBuildSelector>"""),
string(name: 'OPERATING_SYSTEM', value: operatingSystem)
]
)
copyArtifacts(
filter: copyArtifactsFilter,
fingerprintArtifacts: true,
optional: true,
projectName: jobName,
selector: specific(rcpttBuild.getNumber().toString()),
target: resultDir
)
if (htmlReportName != null){
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: "${resultDir}/gui-test-runner/result",
reportFiles: 'results.html',
reportName: htmlReportName,
reportTitles: branchName
])
}
if (logMessageTrendName != null){
archiveArtifacts artifacts: "${resultDir}/gui-test-runner/result/log/**/*"
recordLogMessages logMessageTrendName, resultDir, 'verinice-client.*', 'clientlogparsed-nighly.txt' , 'log4j'
recordLogMessages 'aut-'+logMessageTrendName, resultDir, '.log*', 'autlogparsed-nighly.txt' , 'eclipse'
}
}
def recordLogMessages(logMessageTrendName, resultDir, logFilePattern, targetFilename, logType){
def logPath = "${WORKSPACE}/${resultDir}/gui-test-runner/result/log"
def logFile = "${logPath}/${targetFilename}"
dir(tool(name: 'logparser', type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool')){
sh "./logParser -i ${logType} -d ${logPath} -f ${logFilePattern} -o jenkins -n ${logFile}"
}
recordIssues(
blameDisabled: true,
forensicsDisabled: true,
ignoreFailedBuilds: false,
skipPublishingChecks: true,
qualityGates: [[threshold: 1, type: 'DELTA_ERROR', unstable: true]],
tools: [groovyScript(
id: logMessageTrendName.replaceAll(' ', '_'),
name: logMessageTrendName,
parserId: 'verinice-log-parser',
pattern: "${resultDir}/gui-test-runner/result/log/${targetFilename}"
)
]
)
}
def createPerformancePlot(fileName, group){
def records = readCSV file: fileName
def data = records[1]
def measurementLabels = data.collate(5).collect{it.first().trim()}.findAll{!it.empty}
measurementLabels.each { label->
callPlot fileName, label, group
}
}
def callPlot(String fileName, String plotName, String group) {
echo "Creating plot ${plotName}"
plot csvFileName: 'plot-'+plotName+'.csv',
csvSeries: [[displayTableFlag: false,
exclusionValues: plotName+'-avg,'+plotName+'-min,'+plotName+'-max',
file: fileName,
inclusionFlag: 'INCLUDE_BY_STRING',
url: '']],
group: group,
style: 'line',
title: plotName
}