-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathant.Jenkinsfile
115 lines (101 loc) · 2.17 KB
/
ant.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
pipeline {
agent {
label "local"
}
parameters {
booleanParam(
name: "archive",
description: "Should artifacts be archived?",
defaultValue: false
)
booleanParam(
name: "javadoc",
description: "Should generate Javadoc?",
defaultValue: false
)
}
environment {
JDK_NAME = "Open JDK"
ANT_NAME = "Ant"
ANT_OUTPUT_DIR = "antBuild"
}
options {
skipDefaultCheckout true
timeout(time: 20, unit: "MINUTES")
buildDiscarder logRotator(numToKeepStr: "10", artifactNumToKeepStr: "5")
timestamps()
}
stages {
stage("Preparation") {
steps {
script {
def scmEnv = checkout scm
currentBuild.displayName = "${env.BUILD_NUMBER} ${scmEnv.GIT_COMMIT.take(8)}"
}
}
}
stage("Build") {
steps {
echo "#INFO: Building project"
withAnt(installation: "${env.ANT_NAME}", jdk: "${env.JDK_NAME}") {
sh "ant resolve jar"
}
}
}
stage("Unit tests") {
steps {
echo "#INFO: Running unit tests"
withAnt(installation: "${env.ANT_NAME}", jdk: "${env.JDK_NAME}") {
sh "ant test"
}
}
post {
always {
junit(
testResults: "${env.ANT_OUTPUT_DIR}/junit/result/TEST-*.xml",
healthScaleFactor: 1.0,
skipPublishingChecks: true
)
}
}
}
stage("Archive artifacts") {
when {
beforeAgent true
expression {
params.archive
}
}
steps {
archiveArtifacts(artifacts: "${env.ANT_OUTPUT_DIR}/dist/*.jar", onlyIfSuccessful: true)
}
}
stage("Javadoc") {
when {
beforeAgent true
expression {
params.javadoc
}
}
steps {
echo "#INFO: Publish Javadoc"
withAnt(installation: "${env.ANT_NAME}", jdk: "${env.JDK_NAME}") {
sh "ant docs"
}
}
post {
always {
javadoc(javadocDir: "${env.ANT_OUTPUT_DIR}/docs", keepAll: false)
}
}
}
}
post {
always {
chuckNorris()
}
cleanup {
cleanWs()
}
}
}