-
Notifications
You must be signed in to change notification settings - Fork 28
/
Jenkinsfile
203 lines (182 loc) · 5.88 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
pipeline {
agent {
label 'centos-latest'
}
triggers {
cron('H 23 * * *')
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
skipDefaultCheckout false
}
tools {
maven 'apache-maven-latest'
jdk 'temurin-jdk17-latest'
}
environment {
PUBLISH_LOCATION = 'updates'
BUILD_TIMESTAMP = sh(returnStdout: true, script: 'date +%Y%m%d%H%M').trim()
TYCHO_VERSION = '4.0.7'
TARGET_PLATFORM_PRIMARY = 'eclipse_2023_03-xtext_2_31_0'
TARGET_PLATFORM_LATEST = 'eclipse_2024_06-xtext_nightly'
}
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: 'ECLIPSE_SIGN',
defaultValue: true,
description: '''
Choose whether or not the bundles will be signed.
This is relevant only for nightly and milestone builds.
'''
)
booleanParam(
name: 'PROMOTE',
defaultValue: true,
description: 'Whether to promote the build to the download server.'
)
}
stages {
stage('Display Parameters') {
steps {
script {
env.BUILD_TYPE = params.BUILD_TYPE
env.TARGET_PLATFORM = params.TARGET_PLATFORM
if (env.BRANCH_NAME == 'master') {
// Only sign the master branch.
env.ECLIPSE_SIGN = params.ECLIPSE_SIGN
} else {
env.ECLIPSE_SIGN = false
}
// Only promote signed builds.
env.PROMOTE = params.PROMOTE && (env.ECLIPSE_SIGN == 'true')
}
echo """
BUILD_TIMESTAMP=${env.BUILD_TIMESTAMP}
BUILD_TYPE=${env.BUILD_TYPE}
ECLIPSE_SIGN=${env.ECLIPSE_SIGN}
PROMOTE=${env.PROMOTE}
BRANCH_NAME=${env.BRANCH_NAME}
"""
}
}
stage('Test With Latest') {
steps {
wrap([$class: 'Xvnc', useXauthority: true]) {
dir('.') {
sh '''
mvn \
--fail-at-end \
--no-transfer-progress \
--update-snapshots \
-P!promote \
-Dmaven.repo.local=xpect-local-maven-repository \
-Dmaven.artifact.threads=16 \
-Declipsesign=false \
-Dtycho-version=${TYCHO_VERSION} \
-Dtarget-platform=${TARGET_PLATFORM_LATEST} \
clean \
integration-test
'''
}
}
}
}
stage('Build With Primary') {
steps {
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
wrap([$class: 'Xvnc', useXauthority: true]) {
dir('.') {
sh '''
if [[ $PROMOTE != true ]]; then
promotion_argument='-P!promote'
fi
mvn \
--fail-at-end \
--no-transfer-progress \
--update-snapshots \
$promotion_argument \
-Dmaven.repo.local=xpect-local-maven-repository \
-Dmaven.artifact.threads=16 \
-Declipsesign=${ECLIPSE_SIGN} \
-Dtycho-version=${TYCHO_VERSION} \
-Dtarget-platform=${TARGET_PLATFORM_PRIMARY} \
-Dbuild.id=${BUILD_TIMESTAMP} \
-Dgit.commit=$GIT_COMMIT \
-Dbuild.type=$BUILD_TYPE \
-Dorg.eclipse.justj.p2.manager.build.url=$JOB_URL \
-Dorg.eclipse.justj.p2.manager.relative=$PUBLISH_LOCATION \
clean \
verify
'''
}
}
}
}
}
}
post {
failure {
mail to: '[email protected]',
subject: "[Xpect CI] Build Failure ${currentBuild.fullDisplayName}",
mimeType: 'text/html',
body: "Project: ${env.JOB_NAME}<br/>Build Number: ${env.BUILD_NUMBER}<br/>Build URL: ${env.BUILD_URL}<br/>Console: ${env.BUILD_URL}/console"
archiveArtifacts allowEmptyArchive: true, artifacts: '**'
}
fixed {
mail to: '[email protected]',
subject: "[Xpect CI] Back to normal ${currentBuild.fullDisplayName}",
mimeType: 'text/html',
body: "Project: ${env.JOB_NAME}<br/>Build Number: ${env.BUILD_NUMBER}<br/>Build URL: ${env.BUILD_URL}<br/>Console: ${env.BUILD_URL}/console"
}
success {
archiveArtifacts artifacts: 'org.eclipse.xpect.releng/p2-repository/target/repository/**/*.*,org.eclipse.xpect.releng/p2-repository/target/org.eclipse.xpect.repository-*.zip'
}
always {
junit allowEmptyResults: true, testResults: '**/TEST-*.xml'
}
cleanup {
deleteDir()
sendMatrixMessage()
}
}
}
def sendMatrixMessage() {
def curResult = currentBuild.currentResult
def lastResult = 'NEW'
if (currentBuild.previousBuild != null) {
lastResult = currentBuild.previousBuild.result
}
echo "matrix result check: curResult=${curResult} lastResult=${lastResult}"
if (curResult != 'SUCCESS' || lastResult != 'SUCCESS') {
def color = ''
switch (curResult) {
case 'SUCCESS':
color = '#00FF00'
break
case 'UNSTABLE':
color = '#FFFF00'
break
case 'FAILURE':
color = '#FF0000'
break
default: // e.g. ABORTED
color = '#666666'
}
echo "matrix send message"
matrixSendMessage https: true,
hostname: 'matrix.eclipse.org',
accessTokenCredentialsId: "matrix-token",
roomId: '!aFWRHMCLJDZBzuNIRD:matrix.eclipse.org',
body: "${lastResult} => ${curResult} ${env.BUILD_URL} | ${env.JOB_NAME}#${env.BUILD_NUMBER}",
formattedBody: "<div><font color='${color}'>${lastResult} => ${curResult}</font> | <a href='${env.BUILD_URL}' target='_blank'>${env.JOB_NAME}#${env.BUILD_NUMBER}</a></div>"
}
}