forked from backlogs/redmine_backlogs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redmine20_install.sh
executable file
·125 lines (102 loc) · 3.05 KB
/
redmine20_install.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#/bin/bash
if [[ ! "$WORKSPACE" = /* ]] ||
[[ ! "$PATH_TO_REDMINE" = /* ]] ||
[[ ! "$PATH_TO_BACKLOGS" = /* ]];
then
echo "You should set"\
" WORKSPACE, PATH_TO_REDMINE, PATH_TO_BACKLOGS"\
" environment variables"
echo "You set:"\
"$WORKSPACE"\
"$PATH_TO_REDMINE"\
"$PATH_TO_BACKLOGS"
exit 1;
fi
if [[ "$REDMINE_VER" = 2 ]];
then
export PATH_TO_PLUGINS=./plugins # for redmine 2.0
export GENERATE_SECRET=generate_secret_token
export MIGRATE_PLUGINS=redmine:plugins:migrate
export REDMINE_GIT_REPO=git://github.com/Vanuan/redmine.git
export REDMINE_GIT_TAG=master
else
export PATH_TO_PLUGINS=./vendor/plugins # for redmine < 2.0
export GENERATE_SECRET=generate_session_store
export MIGRATE_PLUGINS=db:migrate_plugins
export REDMINE_GIT_REPO=git://github.com/edavis10/redmine.git
export REDMINE_GIT_TAG=1.4.2
fi
export BUNDLE_GEMFILE=$PATH_TO_REDMINE/Gemfile
clone_redmine()
{
set -e # exit if clone fails
git clone -b master --depth=100 --quiet $REDMINE_GIT_REPO $PATH_TO_REDMINE
cd $PATH_TO_REDMINE
git checkout $REDMINE_GIT_TAG
}
run_tests()
{
# exit if tests fail
set -e
cd $PATH_TO_REDMINE
# create a link to cucumber features
ln -sf $PATH_TO_BACKLOGS/features/ .
mkdir -p coverage
ln -sf `pwd`/coverage $WORKSPACE
# patch fixtures
bundle exec rake redmine:backlogs:prepare_fixtures
# run cucumber
if [ ! -n "${CUCUMBER_FLAGS}" ];
then
export CUCUMBER_FLAGS="--format progress"
fi
bundle exec cucumber $CUCUMBER_FLAGS features
}
uninstall()
{
set -e # exit if migrate fails
cd $PATH_TO_REDMINE
# clean up database
bundle exec rake $MIGRATE_PLUGINS NAME=redmine_backlogs VERSION=0 RAILS_ENV=test
bundle exec rake $MIGRATE_PLUGINS NAME=redmine_backlogs VERSION=0 RAILS_ENV=development
}
run_install()
{
# exit if install fails
set -e
# cd to redmine folder
cd $PATH_TO_REDMINE
echo current directory is `pwd`
# create a link to the backlogs plugin
ln -sf $PATH_TO_BACKLOGS $PATH_TO_PLUGINS/redmine_backlogs
# enable development features
touch backlogs.dev
# install gems
mkdir -p vendor/bundle
bundle install --path vendor/bundle
# copy database.yml
cp $WORKSPACE/database.yml config/
# run redmine database migrations
bundle exec rake db:migrate RAILS_ENV=test --trace
bundle exec rake db:migrate RAILS_ENV=development --trace
# install redmine database
bundle exec rake redmine:load_default_data REDMINE_LANG=en RAILS_ENV=development
# generate session store/secret token
bundle exec rake $GENERATE_SECRET
# enable development features
touch backlogs.dev
# install backlogs
bundle exec rake redmine:backlogs:install labels=no story_trackers=Story task_tracker=Task RAILS_ENV=development --trace
# run backlogs database migrations
bundle exec rake $MIGRATE_PLUGINS RAILS_ENV=test
bundle exec rake $MIGRATE_PLUGINS RAILS_ENV=development
}
while getopts :irtu opt
do case "$opt" in
i) run_install; exit 0;;
r) clone_redmine; exit 0;;
t) run_tests; exit 0;;
u) uninstall; exit 0;;
[?]) echo "i: install; r: clone redmine; t: run tests; u: uninstall";;
esac
done