lib = library(identifier: 'jenkins@2.0.0', retriever: modernSCM([ $class: 'GitSCMSource', remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git', ])) pipeline { agent { docker { label 'Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host' image 'opensearchstaging/ci-runner:release-centos7-clients-v4' alwaysPull true } } options { timeout(time: 1, unit: 'HOURS') } parameters { string( name: 'BASE_DOWNLOAD_PATH', description: 'S3 base path to download artifacts from eg:ml-models/huggingface/sentence-transformers/all-distilroberta-v1. DO NOT include the trailing backlash at the end', trim: true ) string( name: 'VERSION', description: 'Version number of the model', trim: true ) } environment { ARTIFACT_PATH = "${env.BASE_DOWNLOAD_PATH == "ml-models/model_listing" ? "${env.BASE_DOWNLOAD_PATH}/" : "${env.BASE_DOWNLOAD_PATH}/${env.VERSION}/"}" UPLOAD_PATH = "models/ml-models" BUCKET_NAME = credentials('ml-models-bucket-name') } stages{ stage('Parameters Check') { steps { script { if(env.BASE_DOWNLOAD_PATH == "ml-models/model_listing" && env.VERSION.isEmpty()) { echo "Proceeding to download the ml-models/model_listing." } else if (env.BASE_DOWNLOAD_PATH.isEmpty()) { currentBuild.result = 'ABORTED' error('Parameters cannot be empty! Please provide the correct values.') } else if (env.VERSION.isEmpty()) { currentBuild.result = 'ABORTED' error('Parameters cannot be empty! Please provide the correct values.') } else { echo "Proceeding to download the ml-models." } if(env.BASE_DOWNLOAD_PATH.endsWith('/')) { currentBuild.result = 'ABORTED' error('"/" not allowed at the end of the BASE_DOWNLOAD_PATH') } } } } stage('Download the artifacts') { steps { script { downloadFromS3( assumedRoleName: 'get_models', roleAccountNumberCred: 'ml-models-aws-account-number', downloadPath: "${env.ARTIFACT_PATH}", bucketName: "${env.BUCKET_NAME}", localPath: "${env.WORKSPACE}/artifacts", force: true, region: 'us-west-2' ) } } } stage('Sign and Release the artifacts') { steps { script { publishToArtifactsProdBucket( assumedRoleName: 'ml-models-artifacts-upload-role', source: "${env.WORKSPACE}/artifacts/ml-models", destination: "${env.UPLOAD_PATH}", signingPlatform: 'linux', sigType: '.sig', sigOverwrite: true ) } } } } post { always { script { postCleanup() } } } }