summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorArtem Naluzhnyy <A.Naluzhnyy@samsung.com>2019-06-10 16:39:54 +0200
committerArtem Naluzhnyy <a.naluzhnyy@samsung.com>2019-06-10 17:01:31 +0000
commit6ba957886d6ad9b6b7bd6979677ebc88d3c76e26 (patch)
tree447217bfc56306fb9445b7c724721d93453c2e48 /shell
parent9ef7f25b4c4f3ff7eb83518261de099c6ec81787 (diff)
Add JJB template for static code analysis by Coverity Scan service
"onap-gerrit-maven-coverity" JJB template runs 'mvn clean install' and then publishes results to Coverity Scan service for static code analysis. Usage example: - project: name: so-coverity jobs: - onap-gerrit-maven-coverity cron: '@daily' build-node: 'ubuntu1604-builder-4c-4g' project: 'so' project-name: 'so' branch: 'master' mvn-settings: 'so-settings' mvn-goals: 'clean install' mvn-opts: '-Xmx1024m -XX:MaxPermSize=256m' mvn-params: '-Dmaven.test.skip=true' coverity-project-name: 'onap-so' coverity-token: 'PUT COVERITY TOKEN HERE' coverity-user-email: 'PUT USER EMAIL HERE' Issue-ID: CIMAN-260 Signed-off-by: Artem Naluzhnyy <A.Naluzhnyy@samsung.com> Change-Id: I6f4fa6359b5be91932c5a1a1ed7ba0a4068ac152
Diffstat (limited to 'shell')
-rw-r--r--shell/maven-coverity.sh97
1 files changed, 97 insertions, 0 deletions
diff --git a/shell/maven-coverity.sh b/shell/maven-coverity.sh
new file mode 100644
index 000000000..739754211
--- /dev/null
+++ b/shell/maven-coverity.sh
@@ -0,0 +1,97 @@
+#!/bin/bash
+
+# Copyright 2019 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -Eeuxo pipefail
+PS4='+['$(readlink -f "$0")' ${FUNCNAME[0]%main}#$LINENO] '
+
+echo '---> maven-coverity.sh'
+
+#-----------------------------------------------------------------------------
+# Get Coverity Scan build tool
+
+curl \
+ --verbose \
+ --silent \
+ --show-error \
+ --fail \
+ --form "project=${COVERITY_PROJECT_NAME}" \
+ --form "token=${COVERITY_TOKEN}" \
+ --output 'coverity_tool.tgz' \
+ 'https://scan.coverity.com/download/linux64'
+
+tar \
+ --extract \
+ --gunzip \
+ --file='coverity_tool.tgz'
+
+COVERITY_BUILD_TOOL_DIRECTORY=$(
+ head -1 <( \
+ tar \
+ --list \
+ --gunzip \
+ --file='coverity_tool.tgz'
+ )
+)
+COVERITY_BINARY_DIRECTORY="${COVERITY_BUILD_TOOL_DIRECTORY}bin"
+test -d "${COVERITY_BINARY_DIRECTORY}" \
+ || exit 1
+export PATH="${PATH}:${COVERITY_BINARY_DIRECTORY}"
+
+rm 'coverity_tool.tgz'
+
+#-----------------------------------------------------------------------------
+# Build
+
+export MAVEN_OPTS
+
+cov-build \
+ --dir 'cov-int' \
+ "${MVN}" clean install \
+ --errors \
+ --global-settings "${GLOBAL_SETTINGS_FILE}" \
+ --settings "${SETTINGS_FILE}" \
+ ${MAVEN_OPTIONS:=} \
+ ${MAVEN_PARAMS:=}
+
+cov-import-scm \
+ --dir 'cov-int' \
+ --scm 'git'
+
+#-----------------------------------------------------------------------------
+# Submit results to Coverity service
+
+tar \
+ --create \
+ --gzip \
+ --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'
+
+#-----------------------------------------------------------------------------
+
+exit 0