Skip to content

Commit

Permalink
Updating jenkinsfile with using update-alternatives to switch JDK ver…
Browse files Browse the repository at this point in the history
…sion (#4333)

Signed-off-by: Jeff Lu <[email protected]>
  • Loading branch information
jordarlu authored Jan 10, 2024
1 parent eb1d8fe commit 4b0b53d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jenkins/opensearch/publish-min-snapshots.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions tests/jenkins/TestPublishMinSnapshots.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4b0b53d

Please sign in to comment.