-
Notifications
You must be signed in to change notification settings - Fork 0
/
local-docker-build.sh
executable file
·66 lines (57 loc) · 2.42 KB
/
local-docker-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
#!/bin/sh
##################################################################
#
# local-docker-build.sh [BUILD_TYPE] [--stacktrace | --debug]
#
# @params: BUILD_TYPE
# Valid values: ciDev (default), ciOmqa, ciDrop
#
# @author: Branko Minic
#
# This script contains commands to run a gradle build. This script should ONLY be run from within a
# Docker container.
#
# This script will change directory to the workspace (this should be the project's root directory),
# before temporarily renaming the local.properties file (Android Studio specific file), and then
# actually calling the gradle build.
#
# In addition, more details for the build can be obtained by adding either --stacktrace or --debug
# to the parameter list.
#
# To execute the script in Docker, execute the following command from the Terminal, ensuring that
# the <path-to-local-project> is configured for your dev environment.
#
# docker run -v <path-to-local-project-workspace>:/workspace registry.omdev.io:443/<docker-image-name> bash /workspace/local-docker-build.sh [BUILD_TYPE]
#
###################################################################
BUILD_TYPE=${1:-ciDev}
cd /workspace
if [ -f local.properties ]; then
echo "Renaming local.properties -> _local.properties"
mv local.properties _local.properties
else
echo "local.properties doesn't exist - nothing to do!"
fi
echo "**************************************************************"
echo "*** ***"
echo "*** GRADLE BUILD STARTED ***"
echo "*** ***"
echo "**************************************************************"
echo
echo ./gradlew $BUILD_TYPE ${2}
./gradlew $BUILD_TYPE ${2} || EXIT_CODE=$?
echo "**************************************************************"
echo "*** ***"
echo "*** GRADLE BUILD FINISHED ***"
echo "*** ***"
echo "**************************************************************"
if [ -f _local.properties ]; then
echo "Reverting _local.properties -> local.properties"
mv _local.properties local.properties
else
echo "_local.properties doesn't exist - nothing to do!"
fi
if [[ ! -z "${EXIT_CODE}" ]]; then
echo "Gradle build failed with exit code ${EXIT_CODE}"
exit "${EXIT_CODE}"
fi