Blog by Railsware

Capistrano recipe for your favourite CI

The quality of features going to production is very important; and to guarantee the highest quality we use Continuous Integration in our everyday workflow. In one of his recent posts Sergii Boiko has described how to check Travis CI build status before delivering new code to production. Afterwards, we’ve also decided to extract this recipe to capistrano-ci gem and this article will explain how to setup this gem in your deployment process.

Supported continuous integration services:

Installation

Add the following line to your application’s Gemfile:

gem 'capistrano-ci'

And then execute:

$ bundle

Or install it yourself as:

$ gem install capistrano-ci

Add to your Capfile:

require 'capistrano/ci/recipes'

Configuration

Variables list:

Open Source Projects

Setup ci_client and ci_repository variables in your deployment script:

set(:ci_client){ "travis" }
set(:ci_repository){ "organisation-or-user/repository-name" }

Pro Account of Travis-CI:

Additional to ci_client and ci_repository setup ci_access_token:

set(:ci_client){ "travis_pro" }
set(:ci_repository){ "organisation-or-user/repository-name" }
set(:ci_access_token){ "your-pro-access-token" }

To have more information about Travis-CI access token, you can follow this blog post.

CircleCi:

Setup ci_client, ci_repository and ci_access_token in your deployment script:

set(:ci_client){ "circle" }
set(:ci_repository){ "organisation-or-user/repository-name" }
set(:ci_access_token){ "your-circle-access-token" }

Semaphore:

Setup ci_client, ci_repository and ci_access_token in your deployment script:

set(:ci_client){ "semaphore" }
set(:ci_repository){ "organisation-or-user/repository-name" }
set(:ci_access_token){ "your-semaphore-access-token" }

Enable ci:verify task:

before 'deploy' do
  ci.verify
end

# or in case of using capistrano-patch:
before 'patch:create' do
  ci.verify
end

Summary

That’s it, and in case your CI system isn’t supported by our gem, ask us to add it or make pull-requests by yourself!

Exit mobile version