|
| 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