summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJessica Wagantall <jwagantall@linuxfoundation.org>2019-08-01 18:50:34 +0000
committerGerrit Code Review <gerrit@onap.org>2019-08-01 18:50:34 +0000
commitc20700e52af519309ec602bdef49aa9464b3abf1 (patch)
tree2e402f9f17ceb6a4d5fcfe9379cd85de443c0aae
parentb7270fab13da2fa7b5f3c6437cd6dba87e102dd5 (diff)
parentec81f73b2241a9ceeccf6f09bf9de5a09f178a16 (diff)
Merge "Add more attempts to submits Coverity Scan results"
-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
#-----------------------------------------------------------------------------