forked from eclipse-birt/birt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
164 lines (150 loc) · 4.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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
pipeline {
options {
timeout(time: 120, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr:'10'))
disableConcurrentBuilds(abortPrevious: true)
}
agent {
label "centos-latest"
}
tools {
maven 'apache-maven-latest'
jdk 'temurin-jdk17-latest'
}
environment {
CHECKOUT = 'false'
CLONE_URL = 'https://github.com/eclipse-birt/birt'
CLONE_BRANCH = 'master'
}
parameters {
choice(
name: 'BUILD_TYPE',
choices: ['nightly', 'milestone', 'release'],
description: '''
Choose the type of build.
Note that a release build will not promote the build, but rather will promote the most recent milestone build.
'''
)
booleanParam(
name: 'PROMOTE',
defaultValue: true,
description: 'Whether to promote the build to the download server.'
)
}
stages {
stage('Display Parameters') {
steps {
echo "BUILD_TYPE=${params.BUILD_TYPE}"
echo "PROMOTE=${params.PROMOTE}"
echo "BRANCH_NAME=${env.BRANCH_NAME}"
script {
env.BUILD_TYPE = params.BUILD_TYPE
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == null) {
env.WITH_CREDENTIALS = true
if (params.PROMOTE) {
env.MAVEN_PROFILES = "-Pbuild-server -Ppromote"
} else {
env.MAVEN_PROFILES = "-Pbuild-server"
}
} else {
env.WITH_CREDENTIALS = false
env.MAVEN_PROFILES = ""
}
def description = """
BUILD_TYPE=${params.BUILD_TYPE}
WITH_CREDENTIALS=${env.WITH_CREDENTIALS}
MAVEN_PROFILES=${env.MAVEN_PROFILES}
""".trim()
echo description
currentBuild.description = description.replace("\n", "<br/>")
}
}
}
stage('Git Checkout') {
when {
environment name: 'CHECKOUT', value: 'true'
}
steps {
script {
def gitVariables = checkout(
poll: false,
scm: [
$class: 'GitSCM',
branches: [[name: '*' + "${env.CLONE_BRANCH}"]],
doGenerateSubmoduleConfigurations: false,
submoduleCfg: [],
userRemoteConfigs: [[url: "${env.CLONE_URL}.git" ]]
]
)
echo "$gitVariables"
env.GIT_COMMIT = gitVariables.GIT_COMMIT
env.WITH_CREDENTIALS = true
if (params.PROMOTE) {
env.MAVEN_PROFILES = "-Pbuild-server -Ppromote"
} else {
env.MAVEN_PROFILES = "-Pbuild-server"
}
}
}
}
stage('Build') {
steps {
script {
if (env.WITH_CREDENTIALS) {
sshagent (['projects-storage.eclipse.org-bot-ssh']) {
mvn()
}
} else {
mvn()
}
}
}
post {
failure {
mail to: '[email protected]',
subject: "[BIRT CI] Build Failure ${currentBuild.fullDisplayName}",
mimeType: 'text/html',
body: """
Project: ${env.JOB_NAME}<br/>
Build Number: ${env.BUILD_NUMBER}<br/>
Build URL: <a href='${env.BUILD_URL}'>${env.BUILD_URL}</a><br/>
Console: <a href='${env.BUILD_URL}/console'>${env.BUILD_URL}/console</a>
""".trim()
}
fixed {
mail to: '[email protected]',
subject: "[BIRT CI] Back to normal ${currentBuild.fullDisplayName}",
mimeType: 'text/html',
body: """
Project: ${env.JOB_NAME}<br/>
Build Number: ${env.BUILD_NUMBER}<br/>
Build URL: <a href='${env.BUILD_URL}'>${env.BUILD_URL}</a><br/>
Console: <a href='${env.BUILD_URL}/console'>${env.BUILD_URL}/console</a>
""".trim()
}
always {
junit testResults: '**/target/surefire-reports/TEST-*.xml', allowEmptyResults: true
}
}
}
}
}
def void mvn() {
wrap([$class: 'Xvnc', useXauthority: true]) {
sh '''
export MAVEN_OPTS="-XX:MaxRAMPercentage=30"
mvn \
clean \
verify \
-B \
$MAVEN_PROFILES \
-DtestOnCentos=true \
-Dmaven.repo.local=$WORKSPACE/.m2/repository \
-Dorg.eclipse.justj.p2.manager.build.url=$JOB_URL \
-Dbuild.type=$BUILD_TYPE \
-Dgit.commit=$GIT_COMMIT \
-Dorg.eclipse.storage.user=genie.birt \
-Dorg.eclipse.justj.p2.manager.relative=updates
'''
}
}