forked from jenkinsci/docker-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·88 lines (75 loc) · 1.63 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
set -u -o pipefail
# reset in case getops has been used previously in the shell
OPTIND=1
target="build"
build_number="1"
remoting_version="3206.vb_15dcf73f6a_9"
disable_env_props=0
exit_result=0
function exit_if_error() {
if [[ "$exit_result" != "0" ]]
then
echo "Build Failed!"
exit $exit_result
fi
}
while getopts "t:r:b:d" opt; do
case "$opt" in
t)
target=$OPTARG
;;
r)
remoting_version=$OPTARG
;;
b)
build_number=$OPTARG
;;
d)
disable_env_props=1
;;
*)
echo "Invalid flag passed: '${opt}'."
;;
esac
done
# get us to the remaining arguments
shift "$((OPTIND - 1 ))"
if [[ $# -gt 0 ]] ; then
target=$1
shift
fi
if [[ "${disable_env_props}" = "0" ]] ; then
source env.props
export "$(cut -d= -f1 env.props)"
fi
export REGISTRY_ORG=${DOCKERHUB_ORGANISATION:-jenkins4eval}
export REGISTRY_REPO_AGENT=${DOCKERHUB_REPO_AGENT:-agent}
export REGISTRY_REPO_INBOUND_AGENT=${DOCKERHUB_REPO_INBOUND_AGENT:-inbound-agent}
remoting_version=${REMOTING_VERSION:-${remoting_version}}
if [[ "${target}" = "build" ]] ; then
make show
make build
exit_result=$?
exit_if_error
fi
test $exit_result -eq 0 || exit
if [[ "${target}" = "test" ]] ; then
make test
exit_result=$?
exit_if_error
fi
if [[ "${target}" = "publish" ]] ; then
set -x
export REMOTING_VERSION="${remoting_version}"
if [[ -n "${build_number}" ]] ; then
export ON_TAG=true
export BUILD_NUMBER=$build_number
fi
make show
docker buildx bake --push --file docker-bake.hcl linux
exit_result=$?
fi
exit_if_error
echo "Build finished successfully"
exit 0