Install ruby gem from private gitlab repository

Hello

I have ruby on rails project and I can not figure out how to add gem from private gitlab’s repo to Gemfile.
Any ideas?

Have you tried something along these lines?

The problem is that I can not authenticate to a repo, when I am trying to install gem.

Github allows you to do this:
gem ‘my_gem’, git: “https://#{ENV[‘GITHUB_TOKEN’]}:x-oauth-basic@github.com/test_repo/my_gem.git”
or
gem ‘my_gem’, git: “user:password@github.com/test_repo/my_gem.git”

But it does not work for gitlab.
I generated access token here:
git lab/profile/personal_access_tokens

and then pass this token as:
gem ‘my_gem’, git: ‘user:password@github.com/test_repo/my_gem.git?private_token=XXXXXXXXXX’
but no success.

From
https://bundler.io/v1.16/bundle_config.html

In temrinal:
bundle config https://gitlab.com/test_repo/my_gem.git user:pass

And when i try to run bundle install, it still asks for username and password

Solved with next code.
In Gemfile:
gem 'my_gem', git: 'https://gitlab.com/my_repo/my_gem'

Then in terminal:
bundle config https://gitlab.com/my_repo/my_gem username:password