-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
76 lines (69 loc) · 2.38 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
env.OPENCPS_CACHE_VOLUME='gradle_cache_volume_test'
if (env.CHANGE_ID) {
buildPullRequest()
} else {
buildPushCommit()
}
def buildPushCommit() {
node() {
stage('Checkout Source Code') {
checkoutSCM()
}
cleanBuildTest()
}
}
def buildPullRequest() {
node() {
stage('Checkout Source Code') {
checkoutSCM()
}
cleanBuildTest()
}
}
def cleanBuildTest(){
docker.image("openjdk:8u252-jdk").inside("-v ${env.OPENCPS_CACHE_VOLUME}:/root/gradle_cache") {
sh 'mkdir -p /root/.gradle/ && cp -ar /root/gradle_cache/* /root/.gradle/'
stage('Compile & build'){
sh './gradlew -v'
sh './gradlew --no-daemon clean'
sh './gradlew --no-daemon buildService'
sh './gradlew --no-daemon build'
}
stage('Test'){
try {
sh './gradlew --no-daemon test --profile'
} catch (err) {
echo "${err}"
throw err
} finally {
def summary = junit testResults: 'modules/**/TEST-*.xml'
if (env.CHANGE_ID) {
pullRequest.comment(
"${env.GIT_COMMIT_ID}: *Test Summary* - " +
"Total: ${summary.totalCount}, Failures: ${summary.failCount}, " +
"Skipped: ${summary.skipCount}, Passed: ${summary.passCount}. " +
"[Details Report...](${env.JOB_URL}${BUILD_NUMBER}/testReport/)"
)
}
}
}
stage('Code Coverage Report'){
sh './gradlew --no-daemon jacocoTestReport jacocoRootReport'
withCredentials([string(credentialsId: 'codecov-token', variable: 'CODECOV_TOKEN')]) {
sh "curl -s https://codecov.io/bash | bash -s - -t ${CODECOV_TOKEN}"
}
}
}
}
def checkoutSCM() {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions : [[$class : 'CloneOption', shallow: false, timeout: 75],
[$class: 'CleanBeforeCheckout']],
userRemoteConfigs: scm.userRemoteConfigs
])
GIT_REVISION = sh(script: 'git rev-parse HEAD', returnStdout: true)
env.GIT_COMMIT_ID = GIT_REVISION.substring(0, 7)
}