-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
71 lines (65 loc) · 2.28 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
#! groovy
MAKE='make -f Makefile'
node('docker') {
stage('Checkout') {
checkout scm
}
currentBuild.displayName = "PR #${env.ghprbPullId}@${env.NODE_NAME}"
configFileProvider([
configFile(fileId: 'global', variable: 'GLOBAL'),
]) {
global = load env.GLOBAL
}
withEnv([
"COMMIT_SHA=${env.ghprbActualCommit}",
"IMAGE_TAG=${env.ghprbActualCommit.substring(0,8)}",
"PROJECT_NAME=notification-${env.BUILD_NUMBER}",
"ROOTDIR=${global.HOST_WORKSPACE}"
]) {
try {
stage('Unit tests') {
ansiColor('xterm') {
sh("mkdir ./coverage/")
sh("chmod -R o+w .")
sh("${MAKE} test-containerized")
}
}
stage('SonarQube PR analysis') {
String scannerHome = tool 'SonarScanner'
List<String> args = [
"${scannerHome}/bin/sonar-scanner",
'-Dproject.settings=./sonar-project.properties',
"-Dsonar.pullrequest.key=${env.ghprbPullId}",
"-Dsonar.pullrequest.branch=${env.ghprbSourceBranch}",
"-Dsonar.pullrequest.base=${env.ghprbTargetBranch}",
'-Dsonar.buildbreaker.skip=true',
]
withSonarQubeEnv('sonarqube.zenoss.io') {
sh args.join(' ')
}
}
stage('Validate test results') {
junit 'junit.xml'
step([
$class: 'CoberturaPublisher',
autoUpdateHealth: false,
autoUpdateStability: false,
coberturaReportFile: 'coverage/coverage.xml',
failUnhealthy: true,
failUnstable: true,
maxNumberOfBuilds: 0,
onlyStable: false,
sourceEncoding: 'ASCII',
zoomCoverageChart: false,
lineCoverageTargets: '100.0, 90.0, 50.0',
])
}
} finally {
stage('Clean test environment') {
ansiColor('xterm') {
sh("${MAKE} clean")
}
}
}
}
}