Skip to content

Commit

Permalink
Fix setting ruby version (#417)
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <[email protected]>
  • Loading branch information
gaiksaya authored Apr 16, 2024
1 parent 5111a57 commit 2308f3c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jacocoTestReport {
}
}

String version = '6.4.4'
String version = '6.4.5'

task updateVersion {
doLast {
Expand Down
4 changes: 2 additions & 2 deletions tests/jenkins/TestPublishToRubyGems.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 ~/.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 source ~/.rvm/scripts/rvm && rvm use 2.6.0 && ruby --version\n gem cert --add /tmp/workspace/certs/opensearch-rubygems.pem\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
Expand All @@ -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 ~/.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 source ~/.rvm/scripts/rvm && rvm use jruby-9.3.0.0 && ruby --version\n gem cert --add /tmp/workspace/certificate/path\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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
PublishToRubyGemWithArgs_Jenkinsfile.script(groovy.lang.Closure)
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 ~/.rvm/scripts/rvm && rvm use jruby-9.3.0.0 && ruby --version
gem cert --add /tmp/workspace/certificate/path
cd /tmp/workspace/test && gemNameWithVersion=$(ls *.gem)
gem install $gemNameWithVersion
gemName=$(echo $gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem$)//g')
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/jobs/PublishToRubyGems_JenkinsFile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
PublishToRubyGems_JenkinsFile.script(groovy.lang.Closure)
PublishToRubyGems_JenkinsFile.publishToRubyGems({apiKeyCredentialId=ruby-api-key})
publishToRubyGems.sh(#!/bin/bash
gem cert --add /tmp/workspace/certs/opensearch-rubygems.pem
source ~/.rvm/scripts/rvm && rvm use 2.6.0 && ruby --version
gem cert --add /tmp/workspace/certs/opensearch-rubygems.pem
cd /tmp/workspace/dist && gemNameWithVersion=$(ls *.gem)
gem install $gemNameWithVersion
gemName=$(echo $gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem$)//g')
Expand Down
2 changes: 1 addition & 1 deletion vars/publishToRubyGems.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ void call(Map args = [:]) {
String rubyVersion = args.rubyVersion ?: '2.6.0'

sh """#!/bin/bash
gem cert --add ${certPath}
source ~/.rvm/scripts/rvm && rvm use ${rubyVersion} && ruby --version
gem cert --add ${certPath}
cd ${releaseArtifactsDir} && gemNameWithVersion=\$(ls *.gem)
gem install \$gemNameWithVersion
gemName=\$(echo \$gemNameWithVersion | sed -E 's/(-[0-9.]+-*[a-z]*.gem\$)//g')
Expand Down

0 comments on commit 2308f3c

Please sign in to comment.