diff options
author | Artem Naluzhnyy <A.Naluzhnyy@samsung.com> | 2019-08-17 16:21:27 +0200 |
---|---|---|
committer | Artem Naluzhnyy <A.Naluzhnyy@samsung.com> | 2019-08-17 16:21:27 +0200 |
commit | 5ec3b77a6456c8cab8326eeaa6376b757968e568 (patch) | |
tree | a765054ba26d1d9be67c1ca3fb525178304474a6 | |
parent | 02d7b59d47a81083e19fdfeab1d4452c432d8bcc (diff) |
Add DRY_RUN job parameter to bypass actual submission to Coverity server
The Jebkins job parameter can be used during Coverity Scan job initial
configuration or tuning process to avoid unnecessary submission quota
exhaustion.
Issue-ID: CIMAN-260
Signed-off-by: Artem Naluzhnyy <A.Naluzhnyy@samsung.com>
Change-Id: I4dfdf7441b8f31fffa2e4afd62bdd871126cdfd5
-rw-r--r-- | jjb/ci-management/ci-management-coverity.yaml | 5 | ||||
-rw-r--r-- | shell/maven-coverity.sh | 106 |
2 files changed, 60 insertions, 51 deletions
diff --git a/jjb/ci-management/ci-management-coverity.yaml b/jjb/ci-management/ci-management-coverity.yaml index cb7b69f3a..c52559218 100644 --- a/jjb/ci-management/ci-management-coverity.yaml +++ b/jjb/ci-management/ci-management-coverity.yaml @@ -29,6 +29,7 @@ build-timeout: 240 cron: '@daily' disabled: false + dry-run: false git-url: '$GIT_URL/$PROJECT' java-version: openjdk8 mvn-global-settings: global-settings @@ -75,6 +76,10 @@ name: ARCHIVE_ARTIFACTS default: '{archive-artifacts}' description: Artifacts to archive to the logs server. + - bool: + name: DRY_RUN + default: '{dry-run}' + description: Do not submit results to Coverity Scan server at the end of the build. triggers: - timed: '{obj:cron}' diff --git a/shell/maven-coverity.sh b/shell/maven-coverity.sh index 5c0418310..e82de3dff 100644 --- a/shell/maven-coverity.sh +++ b/shell/maven-coverity.sh @@ -52,24 +52,26 @@ fi # and have not exceeded our upload quota limits # See also: https://scan.coverity.com/faq#frequency -CURL_OUTPUT=$( - curl \ - --verbose \ - --silent \ - --show-error \ - --fail \ - --form "project=${COVERITY_PROJECT_NAME}" \ - --form "token=${COVERITY_TOKEN}" \ - 'https://scan.coverity.com/api/upload_permitted' -) +if [ "${DRY_RUN}" != 'true' ]; then + CURL_OUTPUT=$( + curl \ + --verbose \ + --silent \ + --show-error \ + --fail \ + --form "project=${COVERITY_PROJECT_NAME}" \ + --form "token=${COVERITY_TOKEN}" \ + 'https://scan.coverity.com/api/upload_permitted' + ) -IS_COVERITY_UPLOAD_PERMITTED=$( - echo "${CURL_OUTPUT}" \ - | jq '.upload_permitted' -) -if [ x"${IS_COVERITY_UPLOAD_PERMITTED}" != x'true' ]; then - echo "Upload quota reached. Next upload permitted at "$(echo "${CURL_OUTPUT}" | jq '.next_upload_permitted_at') >&2 - exit 1 + IS_COVERITY_UPLOAD_PERMITTED=$( + echo "${CURL_OUTPUT}" \ + | jq '.upload_permitted' + ) + if [ x"${IS_COVERITY_UPLOAD_PERMITTED}" != x'true' ]; then + echo "Upload quota reached. Next upload permitted at "$(echo "${CURL_OUTPUT}" | jq '.next_upload_permitted_at') >&2 + exit 1 + fi fi #----------------------------------------------------------------------------- @@ -177,41 +179,43 @@ cov-manage-emit \ #----------------------------------------------------------------------------- # Submit results to Coverity service -tar \ - --create \ - --gzip \ - --file='results.tgz' \ - 'cov-int' - -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 +if [ "${DRY_RUN}" != 'true' ]; then + tar \ + --create \ + --gzip \ + --file='results.tgz' \ + 'cov-int' + + 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 + 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 fi #----------------------------------------------------------------------------- |