Continuous Integration and Deployment with Gem Prospector

When we designed and built Prospector, we intended for it to be used in a wide variety of scenarios. We didn’t lock our infrastructure down to a Github integration, or relay on Rails only technologies — and this means integrating with a CI service is easy.

Rake Task

When installing the Prospector client gem in your codebase, you’re automatically provided with a rake task to immediately notify the API of usage details. This is true for Rails and RubyMotion apps.

We’ll use this rake task when configuring the CI service, but first let’s disable auto reporting (Rails only) on our production server.

Disable Auto Reporting

If using environment varilables, we’ll just set the ENV var to false which will disable auto reporting on Rails app boot.

Now our production server will skip notifying the API of usage details on boot. Without completing the steps of this post, Prospector will not receive any usage data from your app at all at this point.


To accomplish this for Heroku apps:

heroku config:set PROSPECTOR_ENABLED=false

Configuring CodeShip CI Deployments

In our example, we’ll be configuring an app tested on CodeShip, but this could be configured for any test or integration service.

First, we’ll create a new app on CodeShip. We choose to connect to an existing Github repo for quick configuration, but you can do what you like.

Next we’ll configure the deployment settings for our app on CodeShip to use a custom script. In our case we’re deploying to a connected Heroku app, but we’re able to also use a custom script during deployment to run our rake task and notify the Prospector API of our gemfile details.

bundle exec rake prospector:deliver

Since we’re using CodeShip to deploy our master branch after a successful build, this is the easiest way to integrate.

Configuring CodeShip CI Test

If we were not using CodeShip to deploy, but rather only run our tests, we could add a check to ensure that we only notify the Prospector API when builds are processed on the master branch. This would be the scenario for testing a RubyMotion app for instance, where we are not deploying to a server at all.

First, read the short help article from CodeShip here.

We’ll setup a test command for our project on CodeShip that allows us to run the rake task to notify Prospector only on our master branch.

if [ "$CI_BRANCH" == "master" ]; then bundle exec rake prospector:deliver; fi