forked from micronaut-projects/micronaut-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis-build.sh
executable file
·147 lines (113 loc) · 4.07 KB
/
travis-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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
set -e
set -x
EXIT_STATUS=0
function showLogs {
CLIENT_POD="$(kubectl get pods | grep "example-client" | awk 'FNR <= 1 { print $1 }')"
SERVICE_POD_1="$(kubectl get pods | grep "example-service" | awk 'FNR <= 1 { print $1 }')"
SERVICE_POD_2="$(kubectl get pods | grep "example-service" | awk 'FNR > 1 { print $1 }')"
echo "Build failed! Displaying pod logs"
echo "Client pod logs:"
kubectl logs $CLIENT_POD
echo "Service pod #1 logs:"
kubectl logs $SERVICE_POD_1
echo "Service pod #2 logs:"
kubectl logs $SERVICE_POD_2
}
if [ "${TRAVIS_JDK_VERSION}" == "openjdk11" ] ; then
echo "Check for branch $TRAVIS_BRANCH JDK: $TRAVIS_JDK_VERSION"
./gradlew testClasses --no-daemon --stacktrace|| EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
showLogs
exit $EXIT_STATUS
fi
./gradlew --stop
./gradlew check --no-daemon || EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
showLogs
exit $EXIT_STATUS
fi
./gradlew --stop
./gradlew assemble --no-daemon || EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
showLogs
fi
exit $EXIT_STATUS
fi
if [[ $EXIT_STATUS -eq 0 ]]; then
if [[ -n $TRAVIS_TAG ]]; then
echo "Skipping Tests to Publish Release"
./gradlew pTML assemble --no-daemon || EXIT_STATUS=$?
else
./gradlew --stop
./gradlew testClasses --no-daemon || EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
showLogs
exit $EXIT_STATUS
fi
./gradlew --stop
./gradlew check --no-daemon || EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
showLogs
fi
fi
fi
if [[ $EXIT_STATUS -eq 0 ]]; then
echo "Publishing archives for branch $TRAVIS_BRANCH"
if [[ -n $TRAVIS_TAG ]] || [[ $TRAVIS_BRANCH =~ ^master$ && $TRAVIS_PULL_REQUEST == 'false' ]]; then
echo "Publishing archives"
./gradlew --stop
if [[ -n $TRAVIS_TAG ]]; then
./gradlew bintrayUpload --no-daemon || EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
exit $EXIT_STATUS
fi
else
./gradlew publish --no-daemon || EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
exit $EXIT_STATUS
fi
fi
git config --global user.name "$GIT_NAME"
git config --global user.email "$GIT_EMAIL"
git config --global credential.helper "store --file=~/.git-credentials"
echo "https://$GH_TOKEN:@github.com" > ~/.git-credentials
./gradlew -x javaDocAtReplacement --console=plain --no-daemon docs || EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
exit $EXIT_STATUS
fi
git clone https://${GH_TOKEN}@github.com/micronaut-projects/micronaut-kubernetes.git -b gh-pages gh-pages --single-branch > /dev/null
cd gh-pages
# If this is the master branch then update the snapshot
if [[ $TRAVIS_BRANCH =~ ^master|[12]\..\.x$ ]]; then
mkdir -p snapshot
cp -r ../build/docs/. ./snapshot/
git add snapshot/*
fi
# If there is a tag present then this becomes the latest
if [[ -n $TRAVIS_TAG ]]; then
mkdir -p latest
cp -r ../build/docs/. ./latest/
git add latest/*
version="$TRAVIS_TAG"
version=${version:1}
majorVersion=${version:0:4}
majorVersion="${majorVersion}x"
mkdir -p "$version"
cp -r ../build/docs/. "./$version/"
git add "$version/*"
mkdir -p "$majorVersion"
cp -r ../build/docs/. "./$majorVersion/"
git add "$majorVersion/*"
fi
git commit -a -m "Updating docs for Travis build: https://travis-ci.org/$TRAVIS_REPO_SLUG/builds/$TRAVIS_BUILD_ID" && {
git push origin HEAD || true
}
cd ..
rm -rf gh-pages
if [[ -n $TRAVIS_TAG ]]; then
./gradlew synchronizeWithMavenCentral --no-daemon || EXIT_STATUS=$?
fi
fi
fi
exit $EXIT_STATUS