This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Jenkinsfile.eclipse
169 lines (164 loc) · 7.6 KB
/
Jenkinsfile.eclipse
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
/*
* Copyright (c) Bosch Software Innovations GmbH 2019.
* Copyright (c) Bosch.IO GmbH 2020.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*/
/*
* This is a extended version of the file ./Jenkinsfile, for building
* within the Eclipse Foundation infrastructure, this includes
* - support for signing artifacts
* - support for pushing to Eclipse download repository
*/
def IS_SNAPSHOT_VERSION
pipeline {
agent any
tools {
maven 'apache-maven-3.6.3'
jdk 'oracle-jdk8-latest'
}
parameters {
booleanParam(
name: 'PUSH',
defaultValue: true,
description: 'Push to artifact repository')
booleanParam(
name: 'TAG',
defaultValue: false,
description: 'Tag the build (only if not a snapshot build), version is used as tag name')
string(
name: 'VERSION',
defaultValue: '1.0.0-SNAPSHOT',
description: 'Version to build, SNAPSHOT in name makes it a snapshot build')
}
stages {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// we need to know the version of our project, for that we use the maven-help-plugin
stage('determine version') {
steps {
script {
IS_SNAPSHOT_VERSION = (params.VERSION ==~ /.*-SNAPSHOT/)
}
sh "echo \"VERSION is: ${params.VERSION} with IS_SNAPSHOT_VERSION=${IS_SNAPSHOT_VERSION}\""
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// build antenna
stage('build') {
steps {
// build antenna and also deploy it to an output repository
sh """
rm -rf localRepository
mkdir -p localRepository
rm -rf repository
mkdir -p repository
mvn -Dmaven.repo.local=\$(readlink -f localRepository) \
--batch-mode \
install -DskipTests -DskipITs -Drevision=${params.VERSION}
mvn -Dmaven.repo.local=\$(readlink -f localRepository) \
--batch-mode \
install -DskipTests -DskipITs -Drevision=${params.VERSION} eclipse-jarsigner:sign deploy \
-pl '!core/model-testing,!core/frontend-stubs-testing' \
-DaltDeploymentRepository=localRepositoryFolder::default::file:\$(readlink -f ./repository)
"""
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// push generated repository to download.eclipse.org
// depending on the version, the result gets pushed to
// - https://download.eclipse.org/antenna/snapshots (and all old snapshot builds will be deleted) or
// - https://download.eclipse.org/antenna/releases
stage ('push repository to download.eclipse.org to antenna/snapshots') {
when {
expression {
return params.PUSH && IS_SNAPSHOT_VERSION
}
}
steps {
sh 'find repository -iname \'*.jar\' -print -exec jarsigner -verify {} \\;'
sshagent ( ['projects-storage.eclipse.org-bot-ssh']) {
sh '''
ssh -o StrictHostKeyChecking=no \
rm -rf /home/data/httpd/download.eclipse.org/antenna/snapshots
ssh -o StrictHostKeyChecking=no \
mkdir -p /home/data/httpd/download.eclipse.org/antenna/snapshots
scp -o StrictHostKeyChecking=no \
-r ./repository/* \
[email protected]:/home/data/httpd/download.eclipse.org/antenna/snapshots
'''
}
echo 'Snapshot release is published at https://download.eclipse.org/antenna/snapshots'
}
}
stage ('push repository to download.eclipse.org to antenna/releases') {
when {
expression {
return params.PUSH && ! IS_SNAPSHOT_VERSION
}
}
steps {
sh 'find repository -iname \'*.jar\' -print -exec jarsigner -verify {} \\;'
sshagent ( ['projects-storage.eclipse.org-bot-ssh']) {
sh '''
ssh -o StrictHostKeyChecking=no \
mkdir -p /home/data/httpd/download.eclipse.org/antenna/releases
scp -o StrictHostKeyChecking=no \
-r ./repository/* \
[email protected]:/home/data/httpd/download.eclipse.org/antenna/releases
'''
}
echo 'Release is published at https://download.eclipse.org/antenna/releases'
}
}
stage ('tag build in eclipse/antenna') {
when {
expression {
return params.TAG && ! IS_SNAPSHOT_VERSION
}
}
steps {
script {
try {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'github-bot', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PWD']]) {
sh("git config user.name ${env.GIT_USER}")
sh("git config user.email '${env.GIT_USER}@eclipse.org'")
sh("git tag -a ${params.VERSION} -m 'Weekly build tag'")
sh("git config credential.username ${env.GIT_USER}")
sh("git config credential.helper '!echo password=\$GIT_PWD; echo'")
sh("GIT_ASKPASS=true git push origin --tags")
}
} finally {
sh("git config --unset credential.helper")
sh("git config --unset credential.username")
sh("git config --unset user.name")
sh("git config --unset user.email")
}
}
echo 'Tag is published at https://github.com/eclipse/antenna'
}
}
}
post {
// send a mail on unsuccessful and fixed builds
unsuccessful { // means unstable || failure || aborted
emailext subject: 'Build $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER!',
body: '''Check console output at $BUILD_URL to view the results.''',
recipientProviders: [culprits(), requestor()],
to: '[email protected]'
}
fixed { // back to normal
emailext subject: 'Build $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER!',
body: '''Check console output at $BUILD_URL to view the results.''',
recipientProviders: [culprits(), requestor()],
to: '[email protected]'
}
}
}