3 # Copyright 2019 Samsung Electronics Co., Ltd.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 PS4='+['$(readlink -f "$0")' ${FUNCNAME[0]%main}#$LINENO] '
20 echo '---> maven-coverity.sh'
22 #-----------------------------------------------------------------------------
23 # Check if we are allowed to submit results to Coverity Scan service
24 # and have not exceeded our upload quota limits
25 # See also: https://scan.coverity.com/faq#frequency
33 --form "project=${COVERITY_PROJECT_NAME}" \
34 --form "token=${COVERITY_TOKEN}" \
35 'https://scan.coverity.com/api/upload_permitted'
38 IS_COVERITY_UPLOAD_PERMITTED=$(
39 echo "${CURL_OUTPUT}" \
40 | jq '.upload_permitted'
42 if [ x"${IS_COVERITY_UPLOAD_PERMITTED}" != x'true' ]; then
43 echo "Upload quota reached. Next upload permitted at "$(echo "${CURL_OUTPUT}" | jq '.next_upload_permitted_at') >&2
47 #-----------------------------------------------------------------------------
48 # Get Coverity Scan build tool
55 --form "project=${COVERITY_PROJECT_NAME}" \
56 --form "token=${COVERITY_TOKEN}" \
57 --output 'coverity_tool.tgz' \
58 'https://scan.coverity.com/download/linux64'
65 --form "project=${COVERITY_PROJECT_NAME}" \
66 --form "token=${COVERITY_TOKEN}" \
68 --output 'coverity_tool.md5' \
69 'https://scan.coverity.com/download/linux64'
71 echo -n ' coverity_tool.tgz' >> 'coverity_tool.md5'
72 md5sum --check 'coverity_tool.md5'
77 --file='coverity_tool.tgz'
79 COVERITY_BUILD_TOOL_DIRECTORY=$(
84 --file='coverity_tool.tgz'
87 COVERITY_BINARY_DIRECTORY="${COVERITY_BUILD_TOOL_DIRECTORY}bin"
88 test -d "${COVERITY_BINARY_DIRECTORY}" \
90 export PATH="${PATH}:${COVERITY_BINARY_DIRECTORY}"
92 rm 'coverity_tool.tgz'
94 #-----------------------------------------------------------------------------
101 "${MVN}" clean install \
103 --global-settings "${GLOBAL_SETTINGS_FILE}" \
104 --settings "${SETTINGS_FILE}" \
117 '^Translation unit:$' \
119 's!^[[:digit:]]\+ -> !!' \
120 > 'coverity-scan-analysed-files.log'
122 #-----------------------------------------------------------------------------
123 # Submit results to Coverity service
128 --file='results.tgz' \
136 --form "project=${COVERITY_PROJECT_NAME}" \
137 --form "email=${COVERITY_USER_EMAIL}" \
138 --form "token=${COVERITY_TOKEN}" \
139 --form 'file=@results.tgz' \
140 --form "version=${GIT_COMMIT:0:7}" \
141 --form "description=${GIT_BRANCH}" \
142 'https://scan.coverity.com/builds'
144 #-----------------------------------------------------------------------------