-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
67 lines (60 loc) · 1.55 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
withNode {
stage('checkout') {
checkout scm
}
parallel failFast: false,
lint: {
stage('lint') { lint() }
},
unitTest: {
stage('unitTest') { unitTest() }
}
}
void withNode(Closure body) {
node getNodeName(), {
ansiColor 'xterm', body
}
}
String getNodeName() {
env.NODE_LABEL ?: 'CloudSmall'
}
void unitTest() {
try {
sh './dev test'
}
finally {
publishJUnitReports()
}
}
void lint() {
try {
sh './dev lint'
if (env.BRANCH_NAME != 'main') {
sh "./dev lint-commits"
}
}
finally {
resetFilePermissions()
publishLintReports()
}
}
void publishJUnitReports() {
catchError(buildResult: 'SUCCESS', message: 'Failure in report generation') {
junit testResults: 'build/test-results/test/*.xml', allowEmptyResults: true
publishHTML target: [
allowMissing: true,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'build/reports/tests/test',
reportFiles: 'index.html',
reportName: 'Test summary report'
]
}
}
void publishLintReports() {
archiveArtifacts artifacts: 'megalinter-reports/megalinter.log, linters_logs/ERROR-*', allowEmptyArchive: true
}
void resetFilePermissions() {
sh 'sudo find -mindepth 1 -maxdepth 1 -exec chown --preserve-root --recursive jenkins: {} + || true'
sh 'sudo find -mindepth 1 -maxdepth 1 -exec chmod --preserve-root --recursive u+rw {} + || true'
}