forked from eclipse/xtext-eclipse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
193 lines (181 loc) · 5.86 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
pipeline {
agent {
kubernetes {
label 'xtext-eclipse-' + env.BRANCH_NAME + '-' + env.BUILD_NUMBER
defaultContainer 'xtext-buildenv'
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: jnlp
image: 'eclipsecbi/jenkins-jnlp-agent'
args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
resources:
limits:
memory: "0.4Gi"
cpu: "0.2"
requests:
memory: "0.4Gi"
cpu: "0.2"
volumeMounts:
- mountPath: /home/jenkins/.ssh
name: volume-known-hosts
- name: xtext-buildenv
image: docker.io/smoht/xtext-buildenv:0.7
tty: true
resources:
limits:
memory: "3.6Gi"
cpu: "1.0"
requests:
memory: "3.6Gi"
cpu: "1.0"
volumeMounts:
- name: settings-xml
mountPath: /home/jenkins/.m2/settings.xml
subPath: settings.xml
readOnly: true
- name: m2-repo
mountPath: /home/jenkins/.m2/repository
- name: volume-known-hosts
mountPath: /home/jenkins/.ssh
volumes:
- name: volume-known-hosts
configMap:
name: known-hosts
- name: settings-xml
secret:
secretName: m2-secret-dir
items:
- key: settings.xml
path: settings.xml
- name: m2-repo
emptyDir: {}
'''
}
}
environment {
DOWNSTREAM_JOBS = 'xtext-xtend'
}
parameters {
choice(name: 'target_platform', choices: ['oxygen', 'photon', 'r201809', 'r201812', 'r201903', 'r201906', 'r201909', 'r201912', 'latest' ], description: 'Which Target Platform should be used?')
booleanParam(
name: 'TRIGGER_DOWNSTREAM_BUILD',
defaultValue: (env.BRANCH_NAME.startsWith('milestone')||env.BRANCH_NAME.startsWith('release')),
description: 'Should downstream jobs for the same branch be triggered on successful build?'
)
}
triggers {
parameterizedCron(env.BRANCH_NAME == 'master' ? 'H H(0-1) * * * %target_platform=latest' : '')
}
options {
buildDiscarder(logRotator(numToKeepStr:'5'))
disableConcurrentBuilds()
timeout(time: 150, unit: 'MINUTES')
}
stages {
stage('Checkout') {
steps {
checkout scm
script {
if (params.target_platform == 'latest') {
currentBuild.displayName = "#${BUILD_NUMBER}(4.15)"
} else if (params.target_platform == 'r201912') {
currentBuild.displayName = "#${BUILD_NUMBER}(4.14)"
} else if (params.target_platform == 'r201909') {
currentBuild.displayName = "#${BUILD_NUMBER}(4.13)"
} else if (params.target_platform == 'r201906') {
currentBuild.displayName = "#${BUILD_NUMBER}(4.12)"
} else if (params.target_platform == 'r201903') {
currentBuild.displayName = "#${BUILD_NUMBER}(4.11)"
} else if (params.target_platform == 'r201812') {
currentBuild.displayName = "#${BUILD_NUMBER}(4.10)"
} else if (params.target_platform == 'r201809') {
currentBuild.displayName = "#${BUILD_NUMBER}(4.9)"
} else if (params.target_platform == 'photon') {
currentBuild.displayName = "#${BUILD_NUMBER}(4.8)"
} else {
currentBuild.displayName = "#${BUILD_NUMBER}(4.7)"
}
}
sh '''
sed_inplace() {
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "$@"
else
sed -i "$@"
fi
}
targetfiles="$(find releng -type f -iname '*.target')"
for targetfile in $targetfiles
do
echo "Redirecting target platforms in $targetfile to $JENKINS_URL"
sed_inplace "s?<repository location=\\".*/job/\\([^/]*\\)/job/\\([^/]*\\)/?<repository location=\\"$JENKINS_URL/job/\\1/job/\\2/?" $targetfile
done
'''
}
}
stage('Build') {
steps {
sh """
/home/vnc/.vnc/xstartup.sh
./1-maven-build.sh -s /home/jenkins/.m2/settings.xml --tp=${params.target_platform} --local-repository=/home/jenkins/.m2/repository
"""
}
}
}
post {
always {
junit testResults: '**/target/surefire-reports/*.xml'
}
success {
archiveArtifacts artifacts: 'build/**'
script {
if (params.TRIGGER_DOWNSTREAM_BUILD==true) {
DOWNSTREAM_JOBS.split(',').each {
def downstreamUrl = new URL("${env.JENKINS_URL}/job/$it/job/${env.BRANCH_NAME}")
def boolean downstreamJobExists = sh(script: "curl -L -s -o /dev/null -I -w '%{http_code}' ${downstreamUrl}", returnStdout: true) == "200"
if (downstreamJobExists) {
build job: "$it/${env.BRANCH_NAME}", wait: false, parameters: [booleanParam(name: 'TRIGGER_DOWNSTREAM_BUILD', value: "${params.TRIGGER_DOWNSTREAM_BUILD}")]
}
}
}
}
}
failure {
archiveArtifacts artifacts: '**/target/work/data/.metadata/.log, **/hs_err_pid*.log'
}
cleanup {
script {
def curResult = currentBuild.currentResult
def lastResult = 'NEW'
if (currentBuild.previousBuild != null) {
lastResult = currentBuild.previousBuild.result
}
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'
}
slackSend (
message: "${lastResult} => ${curResult}: <${env.BUILD_URL}|${env.JOB_NAME}#${env.BUILD_NUMBER}>",
botUser: true,
channel: 'xtext-builds',
color: "${color}"
)
}
}
}
}
}