Deploying gem under different platforms (Ruby and Java)



We build two versions of our gem. One for Ruby and one for JRuby . This is achieved by running gem build ./yourgem.gemspec under each platform as in the example below:

$ rvm use ruby
$ gem build ./yourgem.gemspec # this creates file gooddata-2.0.0.gem
$ rvm use jruby
$ rm Gemfile.lock
$ bundle install
$ gem build ./yourgem.gemspec # creates gooddata-2.0.0-java.gem

I can do the same in the script section in my .travis.yml but it doesn’t work using DPL. I’ve tried the following:

- stage: gem-release
    - 2.3
    - jruby-9.1.14
    provider: rubygems
    api_key: $RUBYGEMS_API_KEY

The JRuby deploy job behaves as if it was run under Ruby. Is it possible to deploy a gem under different platforms using DPL?



You can’t use an array for the rvm value (which would have otherwise defined a build matrix at the top level) inside the job definition in jobs.include. To ensure that a job is properly defined, we pick the first value. This is hinted at (but not exactly explicitly stated in

To achieve your goal, define 2 jobs, one with rvm: 2.3 and another with rvm: jruby-* (your choice), and have them each push a gem it builds (remember that the jobs in a build matrix do not have shared storage, so even if you build the gems in previous stages, they will not be available to your deployment stage jobs).


Thank you for the quick reply @BanzaiMan. I’ve tried splitting the deploy part into two separate jobs.

  - stage: gem-release
    name: deploy MRI gem
    rvm: 2.3
      provider: rubygems
      gem: gooddata
      api_key: $RUBYGEMS_API_KEY
  - stage: gem-release
    name: deploy JRuby gem
    rvm: jruby-9.1.14
      provider: rubygems
      gem: gooddata
      api_key: $RUBYGEMS_API_KEY

It’s still building the Ruby version even with rvm: jruby-*. Did I miss anything?


You have a wrong job name defined in You see that the correct Ruby is used


JRuby indeed appears in the log but the output is a Ruby gem.

Successfully built RubyGem
  Name: gooddata
  Version: 2.0.0
  File: gooddata-2.0.0.gem

My deploy script produces gooddata-2.0.0-java.gem both in Travis and locally.


I’m sorry to say, but that’s what your Rake task is doing.

I don’t know why it works on your machine, but I can tell you that you are responsible for this portion of the build.

(I should note that you are running the release task in the script phase of your build, which is semantically speaking misleading.)

We can enable the debug feature for this repo if you would like to gain live access to the VM.


I believe we use the same command to build the gem as travis-ci/dpl. That is gem build ./path-to-gemspec. If the command was really run under the Java platform, RubyGems would build the file gooddata-2.0.0-java.gem (with -java).

Please be so kind and enable the debug feature. I’ll be happy to investigate this further and submit a PR if needed.


My guess is that your gem … is using CRuby instead of JRuby.

At any rate, the debug feature has been enabled on the repository. Be sure to read



@BanzaiMan, thank you for enabling the debugging feature. I can now confirm that dpl is run under CRuby. The command is rvm $(travis_internal_ruby) do... where travis_internal_ruby is 2.4.1 (CRuby). We can see how the command is composed here. I believe that leaving out the rvm do part would have the desired result. I.e. Ruby gems would be deployed under the platform specified in the rvm section, not only under CRuby.

Do you want to fix this? If you confirm my idea, I will be happy to submit a PR.


This is a tough situation, to be completely upfront about it.

We invoke deployment via rvm $(travis_internal_ruby) … because we know ahead of time this Ruby is capable of invoking dpl and deploying build artifacts. The current ruby set in rvm: key may or may not be. Hence the dilemma.

If you are confident that your Ruby (whatever it is) is capable of executing dpl, you could try redefining the travis_internal_ruby function. Without testing at all, I would first try with:

function travis_internal_ruby() {


Thanks for the explanation @BanzaiMan. I completely understand the difficulties of supporting different rubies. It’s probably not worth it in this case. I’ll try the suggested workaround.