Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

How to add a repository to Kochiku

Rob Olson edited this page Aug 11, 2017 · 8 revisions

Add a repository to Kochiku with the web interface.

  1. From the Kochiku homepage, click Repositories in the top right.
  2. Click Add Repository.
  3. Fill out the form and click Create.

If you need to change any form fields after you add a repository, open the project in the web interface and click Settings.

For information about configuring your repository for Kochiku, see kochiku.yml.

The Test Command script

You must point Kochiku to an executable script in your repository with the Test Command field in your project's kochiku.yml. This script is responsible for setting up the test environment and running the tests. The exit code for this script is used to determine if the tests passed or failed. Here's a simple example for a Rails project that uses RSpec:

#!/usr/bin/env bash
set -x

export RAILS_ENV=test

function install_bundler() {
  gem install bundler -v 1.3.5 --conservative
}

function install_gems() {
  bundle check || bundle
}

function prepare_database() {
  bundle exec rake db:drop db:create db:migrate --trace
}

function prepare_and_run() {
  install_bundler &&
  install_gems &&
  prepare_database &&
  bundle exec rspec $(echo $RUN_LIST | tr ',' ' ')
}

prepare_and_run
success=$?
exit $success

Kochiku makes the following environment variables available to your shell script:

  • TEST_RUNNER: The target that was specified in kochiku.yml. Example values are rspec or cucumber.
  • RUN_LIST: A comma-delimited list of test files to execute with this build part.
  • GIT_COMMIT: The ref for the git commit being tested.
  • GIT_BRANCH: The branch name, if a build was requested for a particular branch.
  • KOCHIKU_ENV: The Rails.env of the running Kochiku instance. Possible values are development, staging, production.

Reacting to a green build

Updating tags or branches

When a build succeeds, Kochiku can update git branches for you automatically. In your project's settings, provide a comma-separated list of branches in the ** Update branches to last green commit** field.

Custom tasks

You can point Kochiku to a shell script in your repository that it runs when a build succeeds. To do so, specify the script's location in the on_success_script field of your kochiku.yml.