Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to install gem from private gitlab host from Heroku

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?

like image 627
Simon Iong Avatar asked Oct 16 '25 10:10

Simon Iong


2 Answers

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"
like image 175
John Beynon Avatar answered Oct 19 '25 10:10

John Beynon


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.

like image 36
danielsmith1789 Avatar answered Oct 19 '25 12:10

danielsmith1789



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!