Deploy with Capistrano

1 minute read

You can deploy any kind of application with Capistrano. For detailed information about Capistrano check Don’t forget to Capistrano with a custom script deployment in your projects as it’s not preinstalled on our build servers.

Capistrano with a custom script deployment

To setup a Capistrano deployment on CodeShip, first create a new custom script deployment. From there you can add any commands you need, including installing and calling your Capistrano deployment.

gem install capistrano bundle exec cap $STAGE deploy

Common Errors

Authentication fails

Usually, Capistrano relies on an SSH connection to copy files and execute remote commands. If connecting to your server fails with an error message like asking for a password, please take a look at our documentation on authenticating via SSH public keys for more information.

Capistrano is not installed by default

If you don’t have Capistrano in your Gemfile you need to install it first. Simply add the following command to a script based deployment which runs before the Capistrano deployment.

gem install capistrano

Deployment fails because of detached checkout

Because CodeShip only fetches the last 50 commits as well as checks out your repository in detached head mode, Capistrano may fail the deployment. If this is the case for your setup, please add the following two commands to your deployment script. They will fetch the full history of the repository and switch to the branch you are currently testing.

git fetch --unshallow || true git checkout "${CI_BRANCH}"