Created
August 24, 2013 05:57
-
-
Save sue445/6326333 to your computer and use it in GitHub Desktop.
Jenkins Script for Rails Engine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
readonly JENKINS_RAILS_ENV="test" | |
export LANG=ja_JP.UTF-8 | |
# Jenkins build script | |
run() | |
{ | |
command=$1 | |
echo "$command" | |
eval $command | |
# if error code returned, exit this script with error code | |
RET=$? | |
if [ $RET -ne 0 ]; then | |
exit $RET | |
fi | |
} | |
run "which ruby" | |
run "ruby --version" | |
run "cp spec/dummy/config/database.yml.jenkins spec/dummy/config/database.yml" | |
run "gem install bundler --no-ri --no-rdoc" | |
######################### | |
# parent_app | |
run "cd ./tmp/" | |
if [ -d parent_app ]; then | |
# exists parent_app dir | |
run "cd ./parent_app/" | |
run "git pull --ff" | |
else | |
# not exists parent_app dir | |
run "git clone git@xxxxxxxxxxxxxxxx/parent_app.git" | |
run "cd ./parent_app/" | |
run "git checkout master" | |
fi | |
# mount parent_app/engines/my_engine | |
run "rm -f ./engines/my_engine" | |
run "ln -s ../../../ ./engines/my_engine" | |
echo "bundle install --path vendor/bundle" | |
bundle install --path vendor/bundle | |
RET=$? | |
if [ $RET -ne 0 ]; then | |
# if failed 'bundle install', run 'bundle update' | |
run "bundle update" | |
fi | |
run "cp ../../spec/dummy/config/database.yml.jenkins config/database.yml" | |
run "RAILS_ENV=${JENKINS_RAILS_ENV} bundle exec rake db:migrate:reset" | |
# resetだけだとengineのmigrationが反映されないためもう一度実行する | |
run "RAILS_ENV=${JENKINS_RAILS_ENV} bundle exec rake db:migrate" | |
run "cd ../../" | |
######################### | |
# my_engine | |
echo "bundle install --path vendor/bundle" | |
bundle install --path vendor/bundle | |
RET=$? | |
if [ $RET -ne 0 ]; then | |
# if failed 'bundle install', run 'bundle update' | |
run "bundle update" | |
fi | |
run "RAILS_ENV=${JENKINS_RAILS_ENV} bundle exec rspec" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment