forked from mattbrictson/rails-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins-ci.sh
executable file
·55 lines (46 loc) · 1.38 KB
/
jenkins-ci.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#
# Script used to test this project in Jenkins and continuously deploy the
# development branch to the default capistrano target. Assumes the Jenkins
# user is using bash and rbenv. YMMV.
#
set -e
# Initialize rbenv
source ~/.bashrc
# Ensure we are in the project directory
cd $WORKSPACE
# If ruby version is not installed, install it
if ! ruby -v &> /dev/null; then
rbenv update
rbenv install `cat .ruby-version`
gem install bundler --no-document
rbenv rehash
fi
# Set up local config (don't overwrite database.yml in case it's customized)
cp -n config/database.example.yml config/database.yml || true
cp example.env .env
bundle install
bundle exec rake db:drop || true
bundle exec rake db:create db:migrate
bundle exec rake db:seed
# Webkit needs an X server in order to render.
# See https://github.com/thoughtbot/capybara-webkit/issues/402
if type xvfb-run; then
DISPLAY=localhost:1.0 xvfb-run bundle exec rake
else
bundle exec rake
fi
if bundle show brakeman &> /dev/null; then
bundle exec brakeman --no-progress
fi
if bundle show license_finder &> /dev/null; then
bundle exec license_finder --quiet
fi
# Run a capistrano deploy if we just built the "development" branch.
if bundle show capistrano &> /dev/null; then
if [[ $GIT_BRANCH == origin/development ]]; then
eval `ssh-agent -s`
ssh-add
bundle exec cap staging deploy:migrate_and_restart
fi
fi