-
Notifications
You must be signed in to change notification settings - Fork 51
How to add a repository to Kochiku
Add a repository to Kochiku with the web interface.
- From the Kochiku homepage, click Repositories in the top right.
- Click Add Repository.
- 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.
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 arerspec
orcucumber
. -
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
: TheRails.env
of the running Kochiku instance. Possible values aredevelopment
,staging
,production
.
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.
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.