-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·69 lines (59 loc) · 1.7 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
#!/bin/bash -e
function build() {
local release="verify"
local downstream="no"
while getopts ":rhd" opt; do
case $opt in
r)
release="deploy"
;;
d)
downstream="yes"
;;
h)
cat <<EOF
usage: build [OPTION]... [-- [docker build opts]]
-h show this help.
-c use cache from previous build
-r push resulting image.
-p don't pull base image.
-d trigger downstream builds on Travis CI
EOF
return 0;
;;
:)
echo "$0: option requires an argument -- '$OPTARG'" 1>&2
return 1
;;
*)
echo "$0: invalid option -- '$OPTARG'" 1>&2
return 1
;;
esac
done
shift $((OPTIND-1))
mvn -B ${release}
if [ "${downstream}" == "yes" ]; then
while read -u 10 repo; do
echo "*** Trigger downstream build ${repo}"
URL=$(echo "${repo}" | sed -r "s/([0-9a-zA-Z_-]+).([0-9a-zA-Z_-]+)/\\1%2F\\2/g")
body='{
"request": {
"branch":"master"
}}'
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token ${TRAVIS_TOKEN}" \
-d "$body" \
https://api.travis-ci.org/repo/${URL}/requests
done 10<downstream.txt
fi
}
CURRENT_DIR=$(pwd)
if [ -d ${CURRENT_DIR}/tmp ]; then
rm -rf ${CURRENT_DIR}/tmp
fi
trap "exit 1" INT TERM QUIT
build "$@"