Skip to content

Commit 9c9ee06

Browse files
Add opensearch promotion workflow and jenkins libs for tar (#1354)
* Add opensearch promotion workflow and jenkins libs for tar Signed-off-by: Peter Zhu <[email protected]>
1 parent 99dfb20 commit 9c9ee06

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm))
2+
3+
pipeline {
4+
options {
5+
timeout(time: 1, unit: 'HOURS')
6+
}
7+
agent none
8+
parameters {
9+
choice(
10+
choices: ['distribution-build-opensearch', 'distribution-build-opensearch-dashboards'],
11+
name: 'DISTRIBUTION_JOB_NAME',
12+
description: 'What platform is this distribution build for?.'
13+
)
14+
string(
15+
defaultValue: '',
16+
name: 'DISTRIBUTION_BUILD_NUMBER',
17+
description: 'What is the build id of the above DISTRIBUTION_JOB_NAME that you want to promote? (e.g. 123, 136)',
18+
trim: true
19+
)
20+
string(
21+
defaultValue: '',
22+
name: 'INPUT_MANIFEST',
23+
description: 'What is the input manifest of the above DISTRIBUTION_JOB_NAME that you want to promote? (e.g. 1.2.2/opensearch-1.2.2.yml)',
24+
trim: true
25+
)
26+
choice(
27+
choices: ['linux', 'windows', 'darwin'],
28+
name: 'DISTRIBUTION_PLATFORM',
29+
description: 'What platform is this distribution build for?.'
30+
)
31+
choice(
32+
choices: ['x64', 'arm64'],
33+
name: 'DISTRIBUTION_ARCHITECTURE',
34+
description: 'What architecture is this distribution build for?.'
35+
)
36+
}
37+
stages {
38+
stage('promote artifacts') {
39+
agent {
40+
docker {
41+
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
42+
image 'opensearchstaging/ci-runner:ubuntu2004-x64-docker-buildx0.6.3-qemu5.0-awscli1.22-jdk14'
43+
alwaysPull true
44+
}
45+
}
46+
steps {
47+
script {
48+
promoteArtifacts()
49+
}
50+
}
51+
post() {
52+
always {
53+
script {
54+
cleanWs disableDeferredWipeout: true, deleteDirs: true
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}

vars/promoteArtifacts.groovy

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
void call(Map args = [:]) {
10+
git url: 'https://github.com/opensearch-project/opensearch-build.git', branch: 'main'
11+
def lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm))
12+
13+
String manifest = args.manifest ?: "manifests/${INPUT_MANIFEST}"
14+
def inputManifest = lib.jenkins.InputManifest.new(readYaml(file: manifest))
15+
String filename = inputManifest.build.getFilename()
16+
String version = inputManifest.build.version
17+
18+
def artifactPath = "${DISTRIBUTION_JOB_NAME}/${version}/${DISTRIBUTION_BUILD_NUMBER}/${DISTRIBUTION_PLATFORM}/${DISTRIBUTION_ARCHITECTURE}"
19+
20+
withAWS(role: "${ARTIFACT_DOWNLOAD_ROLE_NAME}", roleAccount: "${AWS_ACCOUNT_PUBLIC}", duration: 900, roleSessionName: 'jenkins-session') {
21+
s3Download(bucket: "${ARTIFACT_BUCKET_NAME}", file: "$WORKSPACE/artifacts", path: "${artifactPath}/", force: true)
22+
}
23+
24+
String build_manifest = "artifacts/$artifactPath/builds/$filename/manifest.yml"
25+
def buildManifest = readYaml(file: build_manifest)
26+
27+
withAWS(role: "${ARTIFACT_PROMOTION_ROLE_NAME}", roleAccount: "${AWS_ACCOUNT_ARTIFACT}", duration: 900, roleSessionName: 'jenkins-session') {
28+
// Core Plugins
29+
println("Start Core Plugin Promotion to artifects.opensearch.org Bucket")
30+
List<String> corePluginList = buildManifest.components.artifacts."core-plugins"[0]
31+
for (String pluginSubPath : corePluginList) {
32+
String pluginSubFolder = pluginSubPath.split('/')[0]
33+
String pluginNameWithExt = pluginSubPath.split('/')[1]
34+
String pluginName = pluginNameWithExt.replace('-' + version + '.zip', '')
35+
String pluginFullPath = ['plugins', pluginName, version].join('/')
36+
s3Upload(bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "releases/$pluginFullPath/", workingDir: "$WORKSPACE/artifacts/$artifactPath/builds/$filename/$pluginSubFolder/"
37+
, includePathPattern: "**/${pluginName}*")
38+
}
39+
40+
41+
// Tar Core/Bundle
42+
println("Start Tar Core/Bundle Promotion to artifacts.opensearch.org Bucket")
43+
String coreFullPath = ['core', filename, version].join('/')
44+
String bundleFullPath = ['bundle', filename, version].join('/')
45+
s3Upload(bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "releases/$coreFullPath/", workingDir: "$WORKSPACE/artifacts/$artifactPath/builds/$filename/dist/"
46+
, includePathPattern: "**/${filename}-min-${version}*")
47+
s3Upload(bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "releases/$bundleFullPath/", workingDir: "$WORKSPACE/artifacts/$artifactPath/dist/$filename/"
48+
, includePathPattern: "**/${filename}*-${version}*")
49+
50+
51+
}
52+
53+
}

0 commit comments

Comments
 (0)