forked from d2iq-archive/dcos-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·88 lines (75 loc) · 2.21 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
#!/bin/bash
# This script does a full build/test of SDK artifacts. This does not upload the artifacts, instead
# see test.sh. This script (and test.sh) are executed by CI upon pull requests to the repository, or
# may be run locally by developers.
# Prevent jenkins from immediately killing the script when a step fails, allowing us to notify github:
set +e
PULLREQUEST="false"
MERGE_FROM="master"
while getopts 'pt:' opt; do
case $opt in
p)
PULLREQUEST="true"
;;
t)
# hack for testing
MERGE_FROM="$OPTARG"
;;
\?)
echo "Unknown option. supported: -p for pull request" >&2
exit 1
;;
esac
done
shift $((OPTIND-1))
REPO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $REPO_ROOT_DIR
# GitHub notifier: reset any statuses from prior builds for this commit
$REPO_ROOT_DIR/tools/github_update.py reset
_notify_github() {
$REPO_ROOT_DIR/tools/github_update.py $1 build:sdk $2
}
merge_master() {
echo "attempting to merge changes from master"
# git won't let you update files without knowing a name
echo "Creating fake user."
command="git config user.email [email protected]"
echo $command
if ! $command; then
return 1 # fail
fi
command="git config user.name Infinity-tools-fake-user"
echo $command
if ! $command; then
return 1 # fail
fi
# Update local branch to include github version of master.
command="git pull origin $MERGE_FROM --no-commit --ff"
echo $command
if ! $command; then
return 1 # fail
fi
return 0 # ok
}
if [ x$PULLREQUEST = "xtrue" ]; then
echo "Merging master into pull request branch."
if ! merge_master; then
_notify_github failure "Merge from master branch failed"
exit 1
else
_notify_github pending "Merge from master branch done"
fi
fi
# Build steps for SDK libraries:
_notify_github pending "SDK build running"
./gradlew clean jar
if [ $? -ne 0 ]; then
_notify_github failure "SDK build failed"
exit 1
fi
./gradlew check
if [ $? -ne 0 ]; then
_notify_github failure "SDK unit tests failed"
exit 1
fi
_notify_github success "SDK build succeeded"