forked from dcos/dcos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_teamcity
executable file
·93 lines (73 loc) · 2.65 KB
/
build_teamcity
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
#!/bin/bash
# Usage: build_teamcity [tree_variant ...]
# tree_variant: Name of a tree variant to build. If no tree variants are passed,
# the "default" and "installer" tree variants are built.
set -x
set -o errexit -o pipefail
function now { date +"%Y-%m-%dT%H:%M:%S.000" | tr -d '\n' ;}
function _scope_msg() {
# Here we want to turn off `-x` that is present when running the bash script
# before we echo the message to teamcity, if we do not do this a "duplicate" echo will
# be printed to stderr and teamcity will error trying to parse the message because
# the format is invalid.
set +x
echo "##teamcity[block$1 timestamp='$(now)' name='$2']"
# Turn `-x` back on now that we're done sending the message to teamcity
set -x
}
function _scope_opened() {
_scope_msg "Opened" $1
}
function _scope_closed() {
_scope_msg "Closed" $1
}
# If no tree variants are specified, build the default and installer variants.
tree_variants=${@:-default installer}
# Fail quickly if docker daemon is not up
systemctl status docker
_scope_opened "cleanup"
# cleanup from previous builds
# *active.json and *.bootstrap.tar.xz must be cleaned up, otherwise
# Teamcity starts picking up artifacts from previous builds.
#
# We manually clean rather than having TeamCity always clean so that
# builds are quicker.
rm -rf dcos-release.config.yaml
rm -rf artifacts/
rm -f packages/*.active.json
rm -f packages/bootstrap.latest
rm -f packages/*.bootstrap.tar.xz
rm -f CHANNEL_NAME
rm -rf build/env
rm -f dcos_generate_config*.sh
rm -rf wheelhouse/
_scope_closed "cleanup"
_scope_opened "setup"
# Force Python stdout/err to be unbuffered to
# have immediate feedback in TeamCity build logs.
export PYTHONUNBUFFERED="notemtpy"
# enable pkgpanda virtualenv *ALWAYS COPY* otherwise the TC cleanup will traverse and corrupt system python
python3.5 -m venv --clear --copies build/env
. build/env/bin/activate
: ${TEAMCITY_BRANCH?"TEAMCITY_BRANCH must be set (determines the tag and testing/ channel)"}
if [[ "$TEAMCITY_BRANCH" == "<default>" ]]
then
echo "ERROR: Building with a branch name of <default> is not supported"
exit 1
fi
TAG="$TEAMCITY_BRANCH"
CHANNEL_NAME=testing/$TAG
echo tag: "$TAG"
echo channel: "$CHANNEL_NAME"
set +x
echo "##teamcity[setParameter name='env.CHANNEL_NAME' value='$CHANNEL_NAME']"
echo "##teamcity[setParameter name='env.TAG' value='$TAG']"
set -x
cp config/dcos-release.config.yaml dcos-release.config.yaml
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
"$DIR"/prep_teamcity
_scope_closed "setup"
release create $TAG $TAG $tree_variants
mkdir -p artifacts
cp -r wheelhouse artifacts/
rm -rf artifacts/dcos_generate_config.*