From e4e7078daf5d08c4181c87c00d5fe326a37d5ec5 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 6 Sep 2023 13:05:14 -0400 Subject: [PATCH] [NodeJS18 Upgrade] Add AL2023 Docker Images Selection by BuildDocker lib (#302) Signed-off-by: Peter Zhu --- build.gradle | 2 +- ...mage_Qualifier_Jenkinsfile_builds_both.txt | 2 +- vars/buildDockerImage.groovy | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 9d8b9a3ba..68e12a83f 100644 --- a/build.gradle +++ b/build.gradle @@ -120,7 +120,7 @@ jacocoTestReport { } } -String version = '5.7.1' +String version = '5.8.0' task updateVersion { doLast { diff --git a/tests/jenkins/jobs/BuildDockerImage_Qualifier_Jenkinsfile_builds_both.txt b/tests/jenkins/jobs/BuildDockerImage_Qualifier_Jenkinsfile_builds_both.txt index 90d29366e..75d8d709d 100644 --- a/tests/jenkins/jobs/BuildDockerImage_Qualifier_Jenkinsfile_builds_both.txt +++ b/tests/jenkins/jobs/BuildDockerImage_Qualifier_Jenkinsfile_builds_both.txt @@ -11,7 +11,7 @@ buildDockerImage.echo(Triggering docker-build) buildDockerImage.string({name=DOCKER_BUILD_GIT_REPOSITORY, value=https://github.com/opensearch-project/opensearch-build}) buildDockerImage.string({name=DOCKER_BUILD_GIT_REPOSITORY_REFERENCE, value=main}) - buildDockerImage.string({name=DOCKER_BUILD_SCRIPT_WITH_COMMANDS, value=id && pwd && cd docker/release && curl -sSL opensearch.linux.x64 -o opensearch-x64.tgz && curl -sSL opensearch.linux.arm64 -o opensearch-arm64.tgz && bash build-image-multi-arch.sh -v 2.0.0-alpha1 -f ./dockerfiles/opensearch.al2.dockerfile -p opensearch -a 'x64,arm64' -r opensearchstaging/opensearch -t 'opensearch-x64.tgz,opensearch-arm64.tgz' -n 33}) + buildDockerImage.string({name=DOCKER_BUILD_SCRIPT_WITH_COMMANDS, value=id && pwd && cd docker/release && curl -sSL opensearch.linux.x64 -o opensearch-x64.tgz && curl -sSL opensearch.linux.arm64 -o opensearch-arm64.tgz && bash build-image-multi-arch.sh -v 2.0.0-alpha1 -f ./dockerfiles/opensearch.al2023.dockerfile -p opensearch -a 'x64,arm64' -r opensearchstaging/opensearch -t 'opensearch-x64.tgz,opensearch-arm64.tgz' -n 33}) buildDockerImage.build({job=docker-build, propagate=true, wait=true, parameters=[null, null, null]}) buildDockerImage.echo(Triggering docker create tag with build number) buildDockerImage.echo(Triggering docker-scan for opensearch version 2.0.0-alpha1) diff --git a/vars/buildDockerImage.groovy b/vars/buildDockerImage.groovy index b30590c51..ad48e1518 100644 --- a/vars/buildDockerImage.groovy +++ b/vars/buildDockerImage.groovy @@ -19,9 +19,16 @@ Library to build Docker Image with different Build Options void call(Map args = [:]) { def lib = library(identifier: 'jenkins@main', retriever: legacySCM(scm)) def inputManifest = lib.jenkins.InputManifest.new(readYaml(file: args.inputManifest)) + def build_version = inputManifest.build.version def build_qualifier = inputManifest.build.qualifier def build_number = args.buildNumber ?: "${BUILD_NUMBER}" String image_tag = "" + String image_base_os = "al2023" + + // Keep al2 for the 1.x versions + if (build_version.split("\\.")[0] == "1") { + image_base_os = "al2" + } if (args.buildDate != null && args.buildDate != 'null'){ image_tag = "." + "${args.buildDate}" @@ -55,8 +62,8 @@ void call(Map args = [:]) { [ 'bash', 'build-image-multi-arch.sh', - "-v ${inputManifest.build.version}${build_qualifier}", - "-f ./dockerfiles/${filename}.al2.dockerfile", + "-v ${build_version}${build_qualifier}", + "-f ./dockerfiles/${filename}.${image_base_os}.dockerfile", "-p ${filename}", "-a 'x64,arm64'", "-r opensearchstaging/${filename}", @@ -75,20 +82,20 @@ void call(Map args = [:]) { wait: true, parameters: [ string(name: 'SOURCE_IMAGE_REGISTRY', value: 'opensearchstaging'), - string(name: 'SOURCE_IMAGE', value: "${filename}:${inputManifest.build.version}${build_qualifier}"), + string(name: 'SOURCE_IMAGE', value: "${filename}:${build_version}${build_qualifier}"), string(name: 'DESTINATION_IMAGE_REGISTRY', value: 'opensearchstaging'), - string(name: 'DESTINATION_IMAGE', value: "${filename}:${inputManifest.build.version}${build_qualifier}.${build_number}${image_tag}") + string(name: 'DESTINATION_IMAGE', value: "${filename}:${build_version}${build_qualifier}.${build_number}${image_tag}") ] } } - echo "Triggering docker-scan for ${filename} version ${inputManifest.build.version}${build_qualifier}" + echo "Triggering docker-scan for ${filename} version ${build_version}${build_qualifier}" dockerScan: { build job: 'docker-scan', propagate: true, wait: true, parameters: [ - string(name: 'IMAGE_FULL_NAME', value: "opensearchstaging/${filename}:${inputManifest.build.version}${build_qualifier}") + string(name: 'IMAGE_FULL_NAME', value: "opensearchstaging/${filename}:${build_version}${build_qualifier}") ] }