Skip to content

Add opensearch promotion workflow and jenkins libs for tar #1354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions jenkins/promotion/tar-promotion.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm))

pipeline {
options {
timeout(time: 1, unit: 'HOURS')
}
agent none
parameters {
choice(
choices: ['distribution-build-opensearch', 'distribution-build-opensearch-dashboards'],
name: 'DISTRIBUTION_JOB_NAME',
description: 'What platform is this distribution build for?.'
)
string(
defaultValue: '',
name: 'DISTRIBUTION_BUILD_NUMBER',
description: 'What is the build id of the above DISTRIBUTION_JOB_NAME that you want to promote? (e.g. 123, 136)',
trim: true
)
string(
defaultValue: '',
name: 'INPUT_MANIFEST',
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)',
trim: true
)
choice(
choices: ['linux', 'windows', 'darwin'],
name: 'DISTRIBUTION_PLATFORM',
description: 'What platform is this distribution build for?.'
)
choice(
choices: ['x64', 'arm64'],
name: 'DISTRIBUTION_ARCHITECTURE',
description: 'What architecture is this distribution build for?.'
)
}
stages {
stage('promote artifacts') {
agent {
docker {
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:ubuntu2004-x64-docker-buildx0.6.3-qemu5.0-awscli1.22-jdk14'
alwaysPull true
}
}
steps {
script {
promoteArtifacts()
}
}
post() {
always {
script {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
}
}
}
53 changes: 53 additions & 0 deletions vars/promoteArtifacts.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.
*/

void call(Map args = [:]) {
git url: 'https://github.com/opensearch-project/opensearch-build.git', branch: 'main'
def lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm))

String manifest = args.manifest ?: "manifests/${INPUT_MANIFEST}"
def inputManifest = lib.jenkins.InputManifest.new(readYaml(file: manifest))
String filename = inputManifest.build.getFilename()
String version = inputManifest.build.version

def artifactPath = "${DISTRIBUTION_JOB_NAME}/${version}/${DISTRIBUTION_BUILD_NUMBER}/${DISTRIBUTION_PLATFORM}/${DISTRIBUTION_ARCHITECTURE}"

withAWS(role: "${ARTIFACT_DOWNLOAD_ROLE_NAME}", roleAccount: "${AWS_ACCOUNT_PUBLIC}", duration: 900, roleSessionName: 'jenkins-session') {
s3Download(bucket: "${ARTIFACT_BUCKET_NAME}", file: "$WORKSPACE/artifacts", path: "${artifactPath}/", force: true)
}

String build_manifest = "artifacts/$artifactPath/builds/$filename/manifest.yml"
def buildManifest = readYaml(file: build_manifest)

withAWS(role: "${ARTIFACT_PROMOTION_ROLE_NAME}", roleAccount: "${AWS_ACCOUNT_ARTIFACT}", duration: 900, roleSessionName: 'jenkins-session') {
// Core Plugins
println("Start Core Plugin Promotion to artifects.opensearch.org Bucket")
List<String> corePluginList = buildManifest.components.artifacts."core-plugins"[0]
for (String pluginSubPath : corePluginList) {
String pluginSubFolder = pluginSubPath.split('/')[0]
String pluginNameWithExt = pluginSubPath.split('/')[1]
String pluginName = pluginNameWithExt.replace('-' + version + '.zip', '')
String pluginFullPath = ['plugins', pluginName, version].join('/')
s3Upload(bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "releases/$pluginFullPath/", workingDir: "$WORKSPACE/artifacts/$artifactPath/builds/$filename/$pluginSubFolder/"
, includePathPattern: "**/${pluginName}*")
}


// Tar Core/Bundle
println("Start Tar Core/Bundle Promotion to artifacts.opensearch.org Bucket")
String coreFullPath = ['core', filename, version].join('/')
String bundleFullPath = ['bundle', filename, version].join('/')
s3Upload(bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "releases/$coreFullPath/", workingDir: "$WORKSPACE/artifacts/$artifactPath/builds/$filename/dist/"
, includePathPattern: "**/${filename}-min-${version}*")
s3Upload(bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "releases/$bundleFullPath/", workingDir: "$WORKSPACE/artifacts/$artifactPath/dist/$filename/"
, includePathPattern: "**/${filename}*-${version}*")


}

}