Skip to content

Commit

Permalink
Adapt RubyGems publish action to opensearch-project/opensearch-build@0…
Browse files Browse the repository at this point in the history
…1613af

Closes opensearch-project#410

Signed-off-by: Earlopain <[email protected]>
  • Loading branch information
Earlopain committed Apr 14, 2024
1 parent c527d2f commit bd2c436
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
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 /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
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 /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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
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 @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion vars/publishToRubyGems.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit bd2c436

Please sign in to comment.