forked from rundeck/rundeck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·259 lines (214 loc) · 6.62 KB
/
build.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/bin/bash
###################################
# script for full rundeck build
###################################
# find wget
if which wget >/dev/null; then
GET="wget -N -nd"
elif which curl >/dev/null; then
GET="curl -O"
else
echo "Couldn't find wget or curl, need one or the other!" 1>&2
exit 1
fi
# configure JAVA_HOME and BUILD_ROOT as required
#export JAVA_HOME=/usr/java/jdk1.5.0_15
if [ -z "$BUILD_ROOT" ] ; then
export BUILD_ROOT=`pwd`/build
fi
if [ ! -f $JAVA_HOME/bin/java ] ; then
echo "ERROR: java is not configured correctly. Set JAVA_HOME."
exit 1
fi
BASEDIR=`pwd`
# VERS will be determined from "version.properties" file in root
#grails version for rundeckapp
GRAILSVERS=1.3.7
JETTYVERS=6.1.21
# this is to provide a workaround for a grails bug for this version of
# grails, where grails does not listen to the gradle config content for proxies
export PROXY_DEFS=""
if [ -n "$http_proxy" ]; then
# assume that http_proxy is of format http://<host>:<port> or <host>:<port>
gradle_proxy_host=`echo $http_proxy|sed 's/http:\/\///'|awk -F ':' '{ print $1 }'`
gradle_proxy_port=`echo $http_proxy|awk -F ':' '{ print $NF }'`
export PROXY_DEFS="-Dhttp.proxyHost=$gradle_proxy_host -Dhttp.proxyPort=$gradle_proxy_port"
fi
prepare_build(){
mkdir -p $BUILD_ROOT
# dl dir is for downloaded files
mkdir -p $BUILD_ROOT/dl
# local dir is for installed components needed for build
mkdir -p $BUILD_ROOT/local
# localrepo dir is the local repository for intermediate build files and other dependencies
mkdir -p $BUILD_ROOT/localrepo
export LOCALREPO=$BUILD_ROOT/localrepo
export LOCALREPOURL=file:$LOCALREPO
export LOCALDEPSREPO=$BASEDIR/dependencies
export LOCALDEPSREPOURL=file:$LOCALDEPSREPO
# extract grails to local dir for use during build of Run Deck
if [ ! -f $BUILD_ROOT/local/grails-$GRAILSVERS/bin/grails ] ; then
if [ ! -z "$PKGREPO" -a -f $PKGREPO/grails/zips/grails-$GRAILSVERS.zip ] ; then
cd $BUILD_ROOT/local
unzip $PKGREPO/grails/zips/grails-$GRAILSVERS.zip
else
# get grails bin distribution
cd $BUILD_ROOT/dl
$GET http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/grails-$GRAILSVERS.zip
cd $BUILD_ROOT/local
unzip $BUILD_ROOT/dl/grails-$GRAILSVERS.zip
fi
fi
export GRAILS_HOME_111=$BUILD_ROOT/local/grails-$GRAILSVERS
# begin checkout of sources
cd $BUILD_ROOT
#determine version
if [ -z "$VERS" ] ; then
export VERS=$( grep version.number= $BASEDIR/version.properties | cut -d= -f 2 )
fi
echo "VERS=$VERS"
if [ -z "$RELNUM" ] ; then
export RELNUM=$( grep version.release.number= $BASEDIR/version.properties | cut -d= -f 2 )
fi
if [ -z "$RELNUM" ] ; then
export RELNUM="0"
fi
echo "RELNUM=$RELNUM"
# do release increment if necessary
if [ "$DO_RELEASE_INCREMENT" = "true" ] ; then
do_release_increment
fi
}
build_rundeck_core(){
#########################
#
# RUN build
#
# NOTE: if $HOME/.ssh/id_dsa does not exist, run ssh-keygen:
# ssh-keygen -t dsa
cd $BASEDIR/core
echo "core build starting..."
echo ./gradlew $PROXY_DEFS -PbuildNum=$RELNUM clean check assemble javadoc
./gradlew $PROXY_DEFS -PbuildNum=$RELNUM clean check assemble javadoc
if [ 0 != $? ]
then
echo "Core build assemble failed: $!"
exit 2
fi
rm -rf $LOCALREPO/rundeck-core
mkdir -p $LOCALREPO/rundeck-core/jars
cp build/libs/rundeck-core-$VERS.jar $LOCALREPO/rundeck-core/jars/rundeck-core-$VERS.jar
if [ 0 != $? ]
then
echo "Core build failed: cannot copy core/build/libs/rundeck-core-$VERS.jar"
exit 2
fi
echo "core build complete"
}
build_rundeckapp(){
#####################
#
# Run Deck build
#
cd $BASEDIR/rundeckapp
# copy the dependencies into the lib directory
cp $LOCALREPO/rundeck-core/jars/rundeck-core-$VERS.jar lib/
MYPATH=$PATH
export GRAILS_HOME=$GRAILS_HOME_111
echo GRAILS_HOME=$GRAILS_HOME
export PATH=$PATH:$GRAILS_HOME/bin
GWORKDIR=$BASEDIR/rundeckapp/work
#echo 'y' to the command to quell y/n prompt on second time running it:
yes | $GRAILS_HOME/bin/grails $PROXY_DEFS -Dgrails.project.work.dir=$GWORKDIR install-plugin $BASEDIR/dependencies/grails-jetty/zips/grails-jetty-1.2-SNAPSHOT.zip
if [ 0 != $? ]
then
echo "failed to install jetty plugin"
exit 2
fi
# # run clean and test
$GRAILS_HOME/bin/grails $PROXY_DEFS -Dgrails.project.work.dir=$GWORKDIR clean
if [ 0 != $? ]
then
echo "Run Deck clean failed"
exit 2
fi
$GRAILS_HOME/bin/grails $PROXY_DEFS -Dgrails.project.work.dir=$GWORKDIR test-app
if [ 0 != $? ]
then
echo "Run Deck tests failed"
exit 2
fi
#run war phase
yes | $GRAILS_HOME/bin/grails $PROXY_DEFS -Dgrails.project.work.dir=$GWORKDIR prod build-launcher
if [ 0 != $? ]
then
echo "Run Deck build failed"
exit 2
fi
# artifacts: rundeck-X.war
mkdir -p $LOCALREPO/rundeck/wars
cp target/rundeck-$VERS.war $LOCALREPO/rundeck/wars/rundeck-$VERS.war
if [ 0 != $? ]
then
echo "Rundeck build failed: cannot copy target/rundeck-$VERS.war"
exit 2
fi
# artifacts: rundeck-launcher-X.jar
mkdir -p $LOCALREPO/rundeck-launcher/jars/
cp target/rundeck-launcher-$VERS.jar $LOCALREPO/rundeck-launcher/jars/rundeck-launcher-$VERS.jar
if [ 0 != $? ]
then
echo "Rundeck build failed: cannot copy target/rundeck-launcher-$VERS.jar"
exit 2
fi
export PATH=$MYPATH
export GRAILS_HOME=
}
do_release_increment(){
RELNUM=$(($RELNUM + 1))
grep -q version.release.number $BASEDIR/version.properties
if [ $? != 0 ] ; then
echo "version.release.number=$RELNUM">> $BASEDIR/version.properties
echo "Added release number to $BASEDIR/version.properties"
else
perl -i'.orig' -p -e "s#^version\.release\.number\s*=.*\$#version.release.number=$RELNUM#" $BASEDIR/version.properties || (echo "Failed to commit release number increment: $!" && exit 2)
echo "Updated release number in $BASEDIR/version.properties"
fi
svn ci -m "Update Release number to $RELNUM" $BASEDIR/version.properties || (echo "Failed to commit release number increment: $!" && exit 2)
echo "Update release number to $RELNUM"
}
if [ "$1" = "-clean" ] ; then
shift
do_clean
fi
DO_RELEASE_INCREMENT=false
if [ "$1" = "-release" ] ; then
shift
#do_release_increment
DO_RELEASE_INCREMENT=true
fi
if [ -z "$*" ] ; then
prepare_build
build_rundeck_core
build_rundeckapp
else
prepare_build
for i in $* ; do
case "$i" in
rundeck_core)
build_rundeck_core
;;
rundeckapp)
build_rundeckapp
;;
server_rpm)
build_server_rpm
;;
*)
echo unknown action: ${i}
exit 1
;;
esac
done
exit 0
fi