@@ -289,11 +289,43 @@ ${SUDO_PREFIX} rm -f "${KUBECONFIG}" || true
289
289
rmdir " ${TEST_HOME} "
290
290
echo " >> ${TEST_HOME} completed at $( date) "
291
291
292
- if [[ " ${MINIKUBE_LOCATION} " != " master" ]]; then
293
- readonly target_url=" https://storage.googleapis.com/minikube-builds/logs/${MINIKUBE_LOCATION} /${JOB_NAME} .txt"
294
- curl -s " https://api.github.com/repos/kubernetes/minikube/statuses/${COMMIT} ?access_token=$access_token " \
295
- -H " Content-Type: application/json" \
296
- -X POST \
297
- -d " {\" state\" : \" $status \" , \" description\" : \" Jenkins\" , \" target_url\" : \" $target_url \" , \" context\" : \" ${JOB_NAME} \" }"
292
+ if [[ " ${MINIKUBE_LOCATION} " == " master" ]]; then
293
+ exit $result
298
294
fi
295
+
296
+ # retry_github_status provides reliable github status updates
297
+ function retry_github_status() {
298
+ local commit=$1
299
+ local context=$2
300
+ local state=$3
301
+ local token=$4
302
+ local target=$5
303
+
304
+ # Retry in case we hit our GitHub API quota or fail other ways.
305
+ local attempt=0
306
+ local timeout=2
307
+ local code=-1
308
+
309
+ while [[ " ${attempt} " -lt 8 ]]; do
310
+ local out=$( mktemp)
311
+ code=$( curl -o " ${out} " -s --write-out " %{http_code}" -L \
312
+ " https://api.github.com/repos/kubernetes/minikube/statuses/${commit} ?access_token=${token} " \
313
+ -H " Content-Type: application/json" \
314
+ -X POST \
315
+ -d " {\" state\" : \" ${state} \" , \" description\" : \" Jenkins\" , \" target_url\" : \" ${target} \" , \" context\" : \" ${context} \" }" || echo 999)
316
+
317
+ # 2xx HTTP codes
318
+ if [[ " ${code} " =~ ^2 ]]; then
319
+ break
320
+ fi
321
+
322
+ cat " ${out} " && rm -f " ${out} "
323
+ echo " HTTP code ${code} ! Retrying in ${timeout} .."
324
+ sleep " ${timeout} "
325
+ attempt=$(( attempt + 1 ))
326
+ timeout=$(( timeout * 2 ))
327
+ done
328
+ }
329
+
330
+ retry_github_status " ${COMMIT} " " ${JOB_NAME} " " ${status} " " ${access_token} " " https://storage.googleapis.com/minikube-builds/logs/${MINIKUBE_LOCATION} /${JOB_NAME} .txt"
299
331
exit $result
0 commit comments