-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathJenkinsfile
executable file
·202 lines (190 loc) · 6.47 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
@Library('gbif-common-jenkins-pipelines') _
pipeline {
agent any
tools {
maven 'Maven 3.8.5'
jdk 'OpenJDK11'
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
skipStagesAfterUnstable()
timestamps()
}
parameters {
separator(name: "release_separator", sectionHeader: "Release Main Project Parameters")
booleanParam(name: 'RELEASE', defaultValue: false, description: 'Do a Maven release')
string(name: 'RELEASE_VERSION', defaultValue: '', description: 'Release version (optional)')
string(name: 'DEVELOPMENT_VERSION', defaultValue: '', description: 'Development version (optional)')
booleanParam(name: 'DRY_RUN_RELEASE', defaultValue: false, description: 'Dry Run Maven release')
separator(name: "release_separator", sectionHeader: "Release Trino UDFs Parameters")
booleanParam(name: 'RELEASE_TRINO', defaultValue: false, description: 'Do a Maven release')
string(name: 'RELEASE_VERSION_TRINO', defaultValue: '', description: 'Release version (optional)')
string(name: 'DEVELOPMENT_VERSION_TRINO', defaultValue: '', description: 'Development version (optional)')
booleanParam(name: 'DRY_RUN_RELEASE_TRINO', defaultValue: false, description: 'Dry Run Maven release')
}
environment {
JETTY_PORT = utils.getPort()
POM_VERSION = readMavenPom().getVersion()
}
stages {
stage('Maven build: Main project (Java 11)') {
when {
allOf {
not { expression { params.RELEASE } };
not { expression { params.RELEASE_TRINO } };
}
}
steps {
configFileProvider([
configFile(fileId: 'org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig1387378707709', variable: 'MAVEN_SETTINGS'),
configFile(fileId: 'org.jenkinsci.plugins.configfiles.custom.CustomConfig1389220396351', variable: 'APPKEYS_TESTFILE')
]) {
sh 'mvn -s ${MAVEN_SETTINGS} clean deploy -Denforcer.skip=true -T 1C -Dparallel=classes -DuseUnlimitedThreads=true -Pgbif-dev -U -Djetty.port=${JETTY_PORT} -Dappkeys.testfile=${APPKEYS_TESTFILE} -B'
}
}
}
stage('Maven build: Trino module (Java 17)') {
tools {
jdk 'OpenJDK17'
}
when {
allOf {
not { expression { params.RELEASE } };
not { expression { params.RELEASE_TRINO } };
}
}
steps {
configFileProvider([
configFile(fileId: 'org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig1387378707709', variable: 'MAVEN_SETTINGS')
]) {
// occurrence-trino-udf needs jdk17 because the trino spi library uses jdk17
sh '''
cd occurrence-trino-udf
mvn -s ${MAVEN_SETTINGS} clean deploy -Pgbif-dev -U -B
'''
}
}
}
stage('Build and push Docker images: Downloads') {
when {
allOf {
not { expression { params.RELEASE } };
not { expression { params.RELEASE_TRINO } };
}
}
steps {
sh '''
build/occurrence-download-spark-docker-build.sh $POM_VERSION
'''
}
}
stage('Build and push Docker images: Table build') {
when {
allOf {
not { expression { params.RELEASE } };
not { expression { params.RELEASE_TRINO } };
}
}
steps {
sh '''
build/occurrence-table-build-spark-docker-build.sh $POM_VERSION
'''
}
}
stage('Trigger WS deploy dev2') {
when {
allOf {
not { expression { params.RELEASE } };
not { expression { params.RELEASE_TRINO } };
branch 'dev';
}
}
steps {
// build job: "occurrence-ws-dev-deploy", wait: false, propagate: false
echo "This stage is commented the occurrence-ws-dev-deploy is currently disabled. Please uncomment this when it's enbaled again"
}
}
stage('Maven release: Main project (Java 11)') {
when {
allOf {
expression { params.RELEASE };
branch 'master';
}
}
environment {
RELEASE_ARGS = utils.createReleaseArgs(params.RELEASE_VERSION, params.DEVELOPMENT_VERSION, params.DRY_RUN_RELEASE)
}
steps {
configFileProvider(
[configFile(fileId: 'org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig1387378707709',
variable: 'MAVEN_SETTINGS_XML')]) {
git 'https://github.com/gbif/occurrence.git'
sh 'mvn -s $MAVEN_SETTINGS_XML -B -Denforcer.skip=true release:prepare release:perform $RELEASE_ARGS'
}
}
}
stage('Maven release: Trino module (Java 17) ') {
tools {
jdk 'OpenJDK17'
}
when {
allOf {
expression { params.RELEASE_TRINO };
branch 'master';
}
}
environment {
RELEASE_ARGS_TRINO = utils.createReleaseArgs(params.RELEASE_VERSION_TRINO, params.DEVELOPMENT_VERSION_TRINO, params.DRY_RUN_RELEASE_TRINO)
}
steps {
configFileProvider(
[configFile(fileId: 'org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig1387378707709',
variable: 'MAVEN_SETTINGS_XML')]) {
git 'https://github.com/gbif/occurrence.git'
sh '''
cd occurrence-trino-udf
mvn -s $MAVEN_SETTINGS_XML -B release:prepare release:perform $RELEASE_ARGS_TRINO
'''
}
}
}
stage('Docker Release: Downloads') {
when {
allOf {
expression { params.RELEASE };
not { expression { params.DRY_RUN_RELEASE } }
branch 'master';
}
}
environment {
VERSION = utils.getReleaseVersion(params.RELEASE_VERSION, POM_VERSION)
}
steps {
sh 'build/occurrence-download-spark-docker-build.sh ${VERSION}'
}
}
stage('Docker Release: Table build') {
when {
allOf {
expression { params.RELEASE };
not { expression { params.DRY_RUN_RELEASE } }
branch 'master';
}
}
environment {
VERSION = utils.getReleaseVersion(params.RELEASE_VERSION, POM_VERSION)
}
steps {
sh 'build/occurrence-table-build-spark-docker-build.sh ${VERSION}'
}
}
}
post {
success {
echo 'Pipeline executed successfully!'
}
failure {
echo 'Pipeline execution failed!'
}
}
}