forked from Dynatrace/openkit-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
74 lines (62 loc) · 1.65 KB
/
Copy pathJenkinsfile
File metadata and controls
74 lines (62 loc) · 1.65 KB
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
def branchPattern = /v\d+\.\d+\.\d+.*/
def targetCompatibilities = [6, 7, 8]
properties([
buildDiscarder(logRotator(numToKeepStr: '10'))
])
timeout(time: 10, unit: 'MINUTES') {
timestamps {
node('default') {
stage('Checkout') {
checkout scm
def currentVersion = sh script: printVersion(), returnStdout: true
currentBuild.displayName += " - ${currentVersion}"
}
stage('Build') {
parallel (targetCompatibilities.collectEntries {[
'Java ' + it, createBuildTask(it)
]})
}
echo "Branch: ${env.BRANCH_NAME}"
stage('Publish') {
withCredentials([file(credentialsId: 'init.gradle', variable: 'INIT_GRADLE')]) {
copy env.INIT_GRADLE, 'init.gradle'
}
// Builds the artifacts with the default target compatibility (Java 6)
// and publishes them to the artifactory
// Adds the build number to the project version
gradlew "assemble publish --init-script init.gradle"
}
}
}
}
def createBuildTask(label) {
return {
node('default') {
withEnv(["TARGET_COMPATIBILITY=${label}"]) {
echo "Build for Java ${label}"
checkout scm
gradlew "clean assemble compileTestJava --parallel"
try {
gradlew "check --continue --parallel"
} finally {
junit testResults: '**/build/test-results/test/TEST-*.xml', keepLongStdio: false
archiveArtifacts artifacts: '**/build/reports/**'
}
}
}
}
}
def copy(String source, String destination) {
if (isUnix()) {
sh "cp -f ${source} ${destination}"
} else {
bat "copy ${source} ${destination}"
}
}
def printVersion() {
if (isUnix()) {
return "./gradlew -q printVersion"
} else {
return "gradlew.bat -q printVersion"
}
}