4

I have a private gitlab host, which host private codes and project, and I host my app in heroku, in that heroku app, we use Gemfile to manage dependence of that heroku app, one of those dependence is from private gitlab host. so my Gemfile is something like this:

gem 'my_greate_gem', '0.0.1', :git => "http://myprivate_gitlab_host/private_gems/my_great_gem.git"

It's seems there's not any tutorial mentions about using private gitlab host to hosting gem in Heroku, but I really don't want to use gemfury. Is there any possible solution for this?

Nakilon
  • 34,866
  • 14
  • 107
  • 142
Simon Iong
  • 191
  • 3
  • 9

2 Answers2

4

Without using Gemfury you would have to pass a username and password in the URL of the gem dependency

 gem 'my_greate_gem', '0.0.1', :git => "http://<username>:<password>@myprivate_gitlab_host/private_gems/my_great_gem.git"
John Beynon
  • 37,398
  • 8
  • 88
  • 97
  • 1
    Thanks for the solution, this fit for me, and I got a way to hidden the password by enabled heroku's user-env-compile feature. If somebody interested in this feture, you can refer to this [gist](https://gist.github.com/masonforest/4048732) – Simon Iong Mar 25 '14 at 06:33
3

The other answer didn't work for me. Also, I prefer a method that allows me to keep credentials out of source. I put the following in my gemfile:

gem 'mygem', git: "https://oauth2:#{ENV['GITLAB_TOKEN']}@gitlab.com/mygroup/mygem.git"

The gitlab token I created has API access. This works for me on heroku if I manually set the GITLAB_TOKEN in the environment variables in settings.

Hope that helps.

danielsmith1789
  • 1,056
  • 1
  • 12
  • 25