-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathgoldberg-build
executable file
·60 lines (52 loc) · 1.62 KB
/
goldberg-build
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
56
57
58
59
60
#! /usr/bin/env bash
if [ $# == 0 ]; then
echo "This script is meant to be run by goldberg"
echo "goldberg-build project ruby code_path build_log_path artefacts_path nice_value environment_variables build_command"
exit 1
fi
project="$1" && shift
ruby="$1" && shift
code_path="$1" && shift
build_log_path="$1" && shift
artifacts_path="$1" && shift
nice_value="$1" && shift
environment_variables="$1" && shift
bundler_options="$1" && shift
build_command="$@"
# echo $project, $ruby, $code_path, $build_log_path, $artifacts_path, $nice_value, $build_command >> $build_log_path
unset BUNDLE_GEMFILE
unset RUBYOPT
unset RAILS_ENV
export BUILD_ARTIFACTS="$artifacts_path"
export BUILD_ARTEFACTS="$artifacts_path"
rvm_script_sourced()
{
if [ -e ~/.rvm/scripts/rvm ]; then
source ~/.rvm/scripts/rvm
elif [ -e /usr/local/rvm/scripts/rvm ]; then
source /usr/local/rvm/scripts/rvm
else
return -1
fi
}
update_bundle()
{
if [ -e Gemfile ]; then
echo "$bundler_options"
bundle check --no-color || bundle install --no-color $bundler_options || gem uninstall bundler && gem install bundler
bundle install --no-color $bundler_options || return -1
else
echo "No Gemfile found"
fi
}
if rvm_script_sourced ; then
rvm use --create "$ruby@global"
(gem list | grep bundler) || gem install bundler
rvm rvmrc trust $code_path
rvm use --create $ruby@goldberg-$project >> $build_log_path 2>&1
fi
cd $code_path
update_bundle >> $build_log_path 2>&1 || exit -1
mkdir -p "$artifacts_path"
if [ -n "$environment_variables" ]; then export $environment_variables; fi
exec nice -n $nice_value $build_command >> $build_log_path 2>&1