summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/maven-coverity.sh45
1 files changed, 33 insertions, 12 deletions
diff --git a/shell/maven-coverity.sh b/shell/maven-coverity.sh
index 22a42c2d5..f263963fe 100644
--- a/shell/maven-coverity.sh
+++ b/shell/maven-coverity.sh
@@ -19,6 +19,9 @@ PS4='+['$(readlink -f "$0")' ${FUNCNAME[0]%main}#$LINENO] '
echo '---> maven-coverity.sh'
+SUBMISSION_ATTEMPTS=5
+SUBMISSION_INITIAL_REST_INTERVAL=30 # seconds, will be doubled after each attempt
+
#-----------------------------------------------------------------------------
# Process parameters for JS/PHP/Ruby files analysis
@@ -148,18 +151,36 @@ tar \
--file='results.tgz' \
'cov-int'
-curl \
- --verbose \
- --silent \
- --show-error \
- --fail \
- --form "project=${COVERITY_PROJECT_NAME}" \
- --form "email=${COVERITY_USER_EMAIL}" \
- --form "token=${COVERITY_TOKEN}" \
- --form 'file=@results.tgz' \
- --form "version=${GIT_COMMIT:0:7}" \
- --form "description=${GIT_BRANCH}" \
- 'https://scan.coverity.com/builds'
+for (( ATTEMPT=1; ATTEMPT<=SUBMISSION_ATTEMPTS; ATTEMPT++ )); do
+ CURL_OUTPUT=$(
+ curl \
+ --verbose \
+ --silent \
+ --show-error \
+ --fail \
+ --write-out '\n%{http_code}' \
+ --form "project=${COVERITY_PROJECT_NAME}" \
+ --form "email=${COVERITY_USER_EMAIL}" \
+ --form "token=${COVERITY_TOKEN}" \
+ --form 'file=@results.tgz' \
+ --form "version=${GIT_COMMIT:0:7}" \
+ --form "description=${GIT_BRANCH}" \
+ 'https://scan.coverity.com/builds'
+ )
+ HTTP_RESPONSE_CODE=$(echo -n "${CURL_OUTPUT}" | tail -1)
+ test x"${HTTP_RESPONSE_CODE}" = x"200" \
+ && break
+
+ sleep "${SUBMISSION_REST_INTERVAL:-$SUBMISSION_INITIAL_REST_INTERVAL}"
+
+ SUBMISSION_REST_INTERVAL=$(( ${SUBMISSION_REST_INTERVAL:-$SUBMISSION_INITIAL_REST_INTERVAL} * 2 ))
+done
+
+HTTP_RESPONSE=$(echo -n "${CURL_OUTPUT}" | head -n -1 | tr -d '\n')
+if [ x"${HTTP_RESPONSE}" != x"Build successfully submitted." ]; then
+ echo "Coverity Scan service responded with '${HTTP_RESPONSE}' while 'Build successfully submitted.' expected." >&2
+ exit 1
+fi
#-----------------------------------------------------------------------------