From 4b0b53d2368235425b6c58c0d7099be8174d9616 Mon Sep 17 00:00:00 2001 From: Jeff Lu Date: Wed, 10 Jan 2024 14:05:05 -0800 Subject: [PATCH] Updating jenkinsfile with using update-alternatives to switch JDK version (#4333) Signed-off-by: Jeff Lu --- jenkins/opensearch/publish-min-snapshots.jenkinsfile | 2 +- tests/jenkins/TestPublishMinSnapshots.groovy | 1 + .../opensearch/publish-min-snapshots.jenkinsfile.txt | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jenkins/opensearch/publish-min-snapshots.jenkinsfile b/jenkins/opensearch/publish-min-snapshots.jenkinsfile index 70f29a03ea..4027cbce9f 100644 --- a/jenkins/opensearch/publish-min-snapshots.jenkinsfile +++ b/jenkins/opensearch/publish-min-snapshots.jenkinsfile @@ -126,7 +126,7 @@ pipeline { steps { script { echo("Switching to Java ${env.javaVersionNumber} on MacOS") - sh("jenv global ${dockerAgent.javaVersion}") + sh("/usr/local/bin/update-alternatives --set java `/usr/local/bin/update-alternatives --list java | grep openjdk-${env.javaVersionNumber}`") sh("java -version") buildManifest( componentName: "OpenSearch", diff --git a/tests/jenkins/TestPublishMinSnapshots.groovy b/tests/jenkins/TestPublishMinSnapshots.groovy index 3cb420cd05..04608b059b 100644 --- a/tests/jenkins/TestPublishMinSnapshots.groovy +++ b/tests/jenkins/TestPublishMinSnapshots.groovy @@ -99,6 +99,7 @@ class TestPublishMinSnapshots extends BuildPipelineTest { return new Yaml().load(('tests/jenkins/data/opensearch-min-3.0.0-snapshot-darwin-build-manifest.yml' as File).text) }) runScript('jenkins/opensearch/publish-min-snapshots.jenkinsfile') + assertThat(getCommands('sh', '/usr/local/bin/update-alternatives'), hasItem('/usr/local/bin/update-alternatives --set java `/usr/local/bin/update-alternatives --list java | grep openjdk-17`')) assertThat(getCommands('sh', 'darwin'), hasItem('./build.sh manifests/3.0.0/opensearch-3.0.0.yml -d tar --component OpenSearch -p darwin -a x64 --snapshot')) assertThat(getCommands('s3Upload', 'min-3.0.0-SNAPSHOT'), hasItems('{file=/tmp/workspace/zip/builds/opensearch/dist/opensearch-min-3.0.0-SNAPSHOT-darwin-x64-latest.tar.gz, bucket=ARTIFACT_PRODUCTION_BUCKET_NAME, path=snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-darwin-x64-latest.tar.gz}', '{file=/tmp/workspace/zip/builds/opensearch/dist/opensearch-min-3.0.0-SNAPSHOT-darwin-x64-latest.tar.gz.sha512, bucket=ARTIFACT_PRODUCTION_BUCKET_NAME, path=snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-darwin-x64-latest.tar.gz.sha512}', diff --git a/tests/jenkins/jenkinsjob-regression-files/opensearch/publish-min-snapshots.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/opensearch/publish-min-snapshots.jenkinsfile.txt index fc3c785fa0..51cd73f3ac 100644 --- a/tests/jenkins/jenkinsjob-regression-files/opensearch/publish-min-snapshots.jenkinsfile.txt +++ b/tests/jenkins/jenkinsjob-regression-files/opensearch/publish-min-snapshots.jenkinsfile.txt @@ -90,7 +90,7 @@ publish-min-snapshots.echo(Executing on agent [label:Jenkins-Agent-MacOS12-X64-Mac1Metal-Multi-Host]) publish-min-snapshots.script(groovy.lang.Closure) publish-min-snapshots.echo(Switching to Java 17 on MacOS) - publish-min-snapshots.sh(jenv global openjdk-17) + publish-min-snapshots.sh(/usr/local/bin/update-alternatives --set java `/usr/local/bin/update-alternatives --list java | grep openjdk-17`) publish-min-snapshots.sh(java -version) publish-min-snapshots.buildManifest({componentName=OpenSearch, inputManifest=manifests/3.0.0/opensearch-3.0.0.yml, platform=darwin, architecture=x64, distribution=tar, snapshot=true}) buildManifest.sh(./build.sh manifests/3.0.0/opensearch-3.0.0.yml -d tar --component OpenSearch -p darwin -a x64 --snapshot)