From bd2c436df1666d3690d2ed495c674595258a469a Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Sun, 14 Apr 2024 21:37:17 +0200 Subject: [PATCH] Adapt RubyGems publish action to https://github.com/opensearch-project/opensearch-build/commit/01613af16774cfe39bf41ab23bf2fdf27a78b95f Closes #410 Signed-off-by: Earlopain <14981592+Earlopain@users.noreply.github.com> --- tests/jenkins/TestPublishToRubyGems.groovy | 4 ++-- tests/jenkins/jobs/PublishToRubyGemWithArgs_Jenkinsfile.txt | 2 +- tests/jenkins/jobs/PublishToRubyGems_JenkinsFile.txt | 2 +- vars/publishToRubyGems.groovy | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/jenkins/TestPublishToRubyGems.groovy b/tests/jenkins/TestPublishToRubyGems.groovy index 21f9d7dd7..8986974b7 100644 --- a/tests/jenkins/TestPublishToRubyGems.groovy +++ b/tests/jenkins/TestPublishToRubyGems.groovy @@ -28,7 +28,7 @@ class TestPublishToRubyGems extends BuildPipelineTest { assertThat(curlCommands, hasItem( "cd /tmp/workspace/dist && curl --fail --data-binary @`ls *.gem` -H 'Authorization:API_KEY' -H 'Content-Type: application/octet-stream' https://rubygems.org/api/v1/gems".toString() )) - assertThat(gemCommands, hasItem("#!/bin/bash\n gem cert --add /tmp/workspace/certs/opensearch-rubygems.pem\n source /usr/share/opensearch/.rvm/scripts/rvm && rvm use 2.6.0 && ruby --version\n cd /tmp/workspace/dist && gemNameWithVersion=\$(ls *.gem)\n gem install \$gemNameWithVersion\n gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P MediumSecurity\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P HighSecurity\n ")) + assertThat(gemCommands, hasItem("#!/bin/bash\n gem cert --add /tmp/workspace/certs/opensearch-rubygems.pem\n source ~/.rvm/scripts/rvm && rvm use 2.6.0 && ruby --version\n cd /tmp/workspace/dist && gemNameWithVersion=\$(ls *.gem)\n gem install \$gemNameWithVersion\n gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P MediumSecurity\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P HighSecurity\n ")) } @Test @@ -40,7 +40,7 @@ class TestPublishToRubyGems extends BuildPipelineTest { def gemCommands = getCommands('sh', 'gem') assertThat(curlCommands, hasItem( "cd /tmp/workspace/test && curl --fail --data-binary @`ls *.gem` -H 'Authorization:API_KEY' -H 'Content-Type: application/octet-stream' https://rubygems.org/api/v1/gems".toString())) - assertThat(gemCommands, hasItem("#!/bin/bash\n gem cert --add /tmp/workspace/certificate/path\n source /usr/share/opensearch/.rvm/scripts/rvm && rvm use jruby-9.3.0.0 && ruby --version\n cd /tmp/workspace/test && gemNameWithVersion=\$(ls *.gem)\n gem install \$gemNameWithVersion\n gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P MediumSecurity\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P HighSecurity\n ")) + assertThat(gemCommands, hasItem("#!/bin/bash\n gem cert --add /tmp/workspace/certificate/path\n source ~/.rvm/scripts/rvm && rvm use jruby-9.3.0.0 && ruby --version\n cd /tmp/workspace/test && gemNameWithVersion=\$(ls *.gem)\n gem install \$gemNameWithVersion\n gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P MediumSecurity\n gem uninstall \$gemName\n gem install \$gemNameWithVersion -P HighSecurity\n ")) } def getCommands(method, text) { diff --git a/tests/jenkins/jobs/PublishToRubyGemWithArgs_Jenkinsfile.txt b/tests/jenkins/jobs/PublishToRubyGemWithArgs_Jenkinsfile.txt index 097237200..6fa1d78e2 100644 --- a/tests/jenkins/jobs/PublishToRubyGemWithArgs_Jenkinsfile.txt +++ b/tests/jenkins/jobs/PublishToRubyGemWithArgs_Jenkinsfile.txt @@ -6,7 +6,7 @@ PublishToRubyGemWithArgs_Jenkinsfile.publishToRubyGems({apiKeyCredentialId=ruby-api-key, gemsDir=test, publicCertPath=certificate/path, rubyVersion=jruby-9.3.0.0}) publishToRubyGems.sh(#!/bin/bash gem cert --add /tmp/workspace/certificate/path - source /usr/share/opensearch/.rvm/scripts/rvm && rvm use jruby-9.3.0.0 && ruby --version + source ~/.rvm/scripts/rvm && rvm use jruby-9.3.0.0 && ruby --version cd /tmp/workspace/test && gemNameWithVersion=$(ls *.gem) gem install $gemNameWithVersion gemName=$(echo $gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem$)//g') diff --git a/tests/jenkins/jobs/PublishToRubyGems_JenkinsFile.txt b/tests/jenkins/jobs/PublishToRubyGems_JenkinsFile.txt index 213a2a216..45fad0462 100644 --- a/tests/jenkins/jobs/PublishToRubyGems_JenkinsFile.txt +++ b/tests/jenkins/jobs/PublishToRubyGems_JenkinsFile.txt @@ -6,7 +6,7 @@ PublishToRubyGems_JenkinsFile.publishToRubyGems({apiKeyCredentialId=ruby-api-key}) publishToRubyGems.sh(#!/bin/bash gem cert --add /tmp/workspace/certs/opensearch-rubygems.pem - source /usr/share/opensearch/.rvm/scripts/rvm && rvm use 2.6.0 && ruby --version + source ~/.rvm/scripts/rvm && rvm use 2.6.0 && ruby --version cd /tmp/workspace/dist && gemNameWithVersion=$(ls *.gem) gem install $gemNameWithVersion gemName=$(echo $gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem$)//g') diff --git a/vars/publishToRubyGems.groovy b/vars/publishToRubyGems.groovy index d5761bbf9..47a99a749 100644 --- a/vars/publishToRubyGems.groovy +++ b/vars/publishToRubyGems.groovy @@ -24,7 +24,7 @@ void call(Map args = [:]) { sh """#!/bin/bash gem cert --add ${certPath} - source /usr/share/opensearch/.rvm/scripts/rvm && rvm use ${rubyVersion} && ruby --version + source ~/.rvm/scripts/rvm && rvm use ${rubyVersion} && ruby --version cd ${releaseArtifactsDir} && gemNameWithVersion=\$(ls *.gem) gem install \$gemNameWithVersion gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')