forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-min-snapshots.jenkinsfile
224 lines (222 loc) · 9.3 KB
/
publish-min-snapshots.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
lib = library(identifier: '[email protected]', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
pipeline {
options {
timeout(time: 1, unit: 'HOURS')
}
agent none
environment {
AGENT_LINUX_X64 = 'Jenkins-Agent-AL2023-X64-M54xlarge-Docker-Host'
AGENT_LINUX_ARM64 = 'Jenkins-Agent-AL2023-Arm64-M6g4xlarge-Docker-Host'
AGENT_MACOS_X64 = 'Jenkins-Agent-MacOS13-X64-Mac1Metal-Multi-Host'
AGENT_MACOS_ARM64 = 'Jenkins-Agent-MacOS13-ARM64-Mac2M2proMetal-Multi-Host'
AGENT_WINDOWS_X64 = 'Jenkins-Agent-Windows2019-X64-M54xlarge-Docker-Host'
IMAGE_WINDOWS_ZIP = 'opensearchstaging/ci-runner:ci-runner-windows2019-opensearch-build-v1' // required for windows to build zip distribution
}
parameters {
string(
name: 'INPUT_MANIFEST',
description: 'Input manifest under the manifests folder, e.g. 2.0.0/opensearch-2.0.0.yml.',
trim: true
)
}
stages {
stage('Detect Docker-images') {
agent {
docker {
label AGENT_LINUX_X64
image 'docker/library/alpine:3'
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
dockerAgent = detectDockerAgent()
env.javaVersionNumber = dockerAgent.javaVersion.replaceAll("[^0-9]", "") // Only get number
currentBuild.description = INPUT_MANIFEST
}
}
}
stage('Build OpenSearch-min Snapshots') {
parallel {
stage('linux-x64-tar') {
agent {
docker {
label AGENT_LINUX_X64
image dockerAgent.image
args dockerAgent.args
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
buildManifest(
componentName: "OpenSearch",
inputManifest: "manifests/${INPUT_MANIFEST}",
platform: 'linux',
architecture: 'x64',
distribution: 'tar',
snapshot: true
)
echo("Uploading linux x64 tar min snapshots to S3")
uploadMinSnapshotsToS3(
fileActions: [createSha512Checksums()],
distribution: 'tar'
)
}
}
post {
always {
postCleanup()
}
}
}
stage('linux-arm64-tar') {
agent {
docker {
label AGENT_LINUX_ARM64
image dockerAgent.image
args dockerAgent.args
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
buildManifest(
componentName: "OpenSearch",
inputManifest: "manifests/${INPUT_MANIFEST}",
platform: 'linux',
architecture: 'arm64',
distribution: 'tar',
snapshot: true
)
echo("Uploading linux arm64 tar min snapshots to S3")
uploadMinSnapshotsToS3(
fileActions: [createSha512Checksums()],
distribution: 'tar'
)
}
}
post {
always {
postCleanup()
}
}
}
stage('macos-x64-tar') {
agent {
node {
label AGENT_MACOS_X64
}
}
steps {
script {
echo("Switching to Java ${env.javaVersionNumber} on MacOS X64")
sh("/usr/local/bin/update-alternatives --set java `/usr/local/bin/update-alternatives --list java | grep openjdk-${env.javaVersionNumber}`")
sh("java -version")
buildManifest(
componentName: "OpenSearch",
inputManifest: "manifests/${INPUT_MANIFEST}",
platform: 'darwin',
architecture: 'x64',
distribution: 'tar',
snapshot: true
)
echo("Uploading darwin x64 tar min snapshots to S3")
uploadMinSnapshotsToS3(
fileActions: [createSha512Checksums()],
distribution: 'tar'
)
}
}
post {
always {
postCleanup()
}
}
}
stage('macos-arm64-tar') {
agent {
node {
label AGENT_MACOS_ARM64
}
}
steps {
script {
echo("Switching to Java ${env.javaVersionNumber} on MacOS ARM64")
sh("/opt/homebrew/bin/update-alternatives --set java `/opt/homebrew/bin/update-alternatives --list java | grep openjdk-${env.javaVersionNumber}`")
sh("java -version")
buildManifest(
componentName: "OpenSearch",
inputManifest: "manifests/${INPUT_MANIFEST}",
platform: 'darwin',
architecture: 'arm64',
distribution: 'tar',
snapshot: true
)
echo("Uploading darwin arm64 tar min snapshots to S3")
uploadMinSnapshotsToS3(
fileActions: [createSha512Checksums()],
distribution: 'tar'
)
}
}
post {
always {
postCleanup()
}
}
}
stage('windows-x64-zip') {
agent {
docker {
label AGENT_WINDOWS_X64
image IMAGE_WINDOWS_ZIP
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
retry(3) {
echo("Switching to Java ${env.javaVersionNumber} on Windows Docker Container")
sh("scoop reset `scoop list jdk | cut -d ' ' -f1 | grep ${env.javaVersionNumber} | head -1`")
buildManifest(
componentName: "OpenSearch",
inputManifest: "manifests/${INPUT_MANIFEST}",
platform: 'windows',
architecture: 'x64',
distribution: 'zip',
snapshot: true
)
echo("Uploading windows x64 zip min snapshots to S3")
uploadMinSnapshotsToS3(
fileActions: [createSha512Checksums()],
distribution: 'zip'
)
}
}
}
post {
always {
postCleanup()
}
}
}
}
}
}
}