Docs Navigation

Building a project with private gems

Either use a hosted private gem repository such as Gemfury, or follow this procedure:

- Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

curl -u 'masonforest' -d '{"scopes":["repo"], "note":"Semaphore CI private gem"}' https://api.github.com/authorizations

- Authenticate bundler to GitHub via OAuth Token

Add this line to your Gemfile replacing "your_token" with the token you got from first step. In this example we are installing the 'ventana' gem:

gem 'ventana', git: "https://your_token:x-oauth-basic@github.com/renderedtext/ventana.git"

More secure alternative:

Storing the OAuth token in an environment variable

For additional security you can store your OAuth token in an environment variable. This way your token is not included in your codebase which is insecure. However this technique require form you to export OAuth token in your development environment too (Best way is to export it in ~/.zshrc or ~/.bashrc).

Change the line in your Gemfile to

gem 'ventana', git: "https://#{ENV['GITHUB_TOKEN']}:x-oauth-basic@github.com/thoughtbot/ventana.git"

Then export token on Semaphore using the token you got from above:

export GITHUB_TOKEN=your_token

Now bundle localy and you are ready to build on Semaphore!

Third alternative: additional SSH key

As of November 2013 Semaphore supports saving and using custom configuration files, including SSH keys. Follow this guide to set up an additional SSH key which can give your build or deploy permissions to pull private dependencies.

This option works only for 1 private gem and SSH key. If you have more than one, use one of the methods listed above.

Semaphore Docs are open source — Edit on GitHub

Newsletter

Occasional lightweight product and blog updates. Unsubscribe at any time.

2009-2017 © Rendered Text. All rights reserved. Terms of Service, Privacy policy, Security.