-
Notifications
You must be signed in to change notification settings - Fork 5
/
Jenkinsfile
141 lines (126 loc) · 6.03 KB
/
Jenkinsfile
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
slackNotification null, 'Build Started', null
def startedAt = java.time.Instant.now()
node {
try {
timestamps {
stage('Prepare') {
checkout scm
sh """
printenv | sort
tools/install-compilers.sh
tools/real-clean-workspace.sh
pwd
./.gradlew --version
./.gradlew --stop
"""
}
stage('Compile Java') {
sh "./.gradlew classes testClasses integrationTestClasses"
}
stage('Java unit test') {
try {
sh "./.gradlew test --exclude-task :product:system-test:test"
} finally {
// Prevent junit publisher to fail if Gradle has skipped the test
sh "find . -name '*.xml' | grep '/build/test-results/test/' | xargs --no-run-if-empty touch"
junit '**/build/test-results/test/*.xml'
}
}
stage('Integration test') {
try {
sh "./.gradlew integrationTest"
} finally {
// Prevent junit publisher to fail if Gradle has skipped the test
sh "find . -name '*.xml' | grep '/build/test-results/integrationTest/' | xargs --no-run-if-empty touch"
junit '**/build/test-results/integrationTest/*.xml'
}
}
stage('Frontend webpack') {
lock("Codekvast-${env.BRANCH_NAME}-webpack") {
try {
sh "./.gradlew :product:server:dashboard:frontendBuild"
} finally {
// Prevent junit publisher to fail if Gradle has skipped the test
sh "find . -name '*.xml' | grep '/build/test-results/frontendTest/' | xargs --no-run-if-empty touch"
junit '**/build/test-results/frontendTest/*.xml'
publishHTML([allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'product/server/dashboard/build/reports/frontend-coverage',
reportFiles: 'index.html',
reportName: 'Frontend Coverage Report'])
}
}
}
stage('System test') {
try {
sh "./.gradlew :product:system-test:test"
} finally {
// archiveArtifacts '**/system-test/build/*.log'
// Prevent junit publisher to fail if Gradle has skipped the test
sh "find . -name '*.xml' | grep 'system-test/build/test-results/test/' | xargs --no-run-if-empty touch"
junit '**/system-test/build/test-results/test/*.xml'
}
}
stage('Documentation & reports') {
sh "./.gradlew -Dorg.gradle.configureondemand=false :product:docs:build :product:aggregateJavadoc"
publishHTML([allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'product/docs/build/asciidoc/html5',
reportFiles: 'CodekvastUserManual.html',
reportName: 'User Manual'])
publishHTML([allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'product/build/docs/javadoc',
reportFiles: 'index.html',
reportName: 'API docs'])
step([$class: 'JacocoPublisher',
classPattern: 'product/**/build/classes/main',
execPattern: '**/build/jacoco/*.exec',
buildOverBuild: true,
changeBuildStatus: true,
deltaBranchCoverage: '10',
deltaClassCoverage: '10',
deltaComplexityCoverage: '10',
deltaInstructionCoverage: '10',
deltaLineCoverage: '10',
deltaMethodCoverage: '10',
maximumBranchCoverage: '30',
minimumBranchCoverage: '20',
maximumClassCoverage: '90',
minimumClassCoverage: '80',
maximumComplexityCoverage: '40',
minimumComplexityCoverage: '30',
maximumInstructionCoverage: '50',
minimumInstructionCoverage: '40',
maximumLineCoverage: '80',
minimumLineCoverage: '65',
maximumMethodCoverage: '70',
minimumMethodCoverage: '60',
])
echo "Running tools/uptodate-report.sh"
sh 'tools/uptodate-report.sh'
archiveArtifacts 'build/reports/**'
}
}
slackNotification 'good', "Build finished", startedAt
} catch(err) {
slackNotification 'danger', "Build failed", startedAt
throw err
} finally {
stage('Cleanup') {
sh 'tools/jenkins-cleanup.sh'
}
}
}
def prettyDuration(java.time.Duration d) {
// Transform e.g., "PT3M42.8934S" to "3m 42s"
d.toString().replaceFirst("^PT", "").replaceAll("([A-Z])", "\$1 ").replaceAll("\\.[0-9]+", "").toLowerCase()
}
def slackNotification(color, message, startedAt) {
def duration = startedAt == null ? "" : " in ${prettyDuration(java.time.Duration.between(startedAt, java.time.Instant.now()))}"
def console = "${env.BUILD_URL}/console".replace('//console', '/console')
slackSend color: color, message: "${java.time.LocalDateTime.now()} ${message}${duration} ${console}", teamDomain: 'codekvast', channel: '#builds', tokenCredentialId: 'codekvast.slack.com'
}