Add static code analysis support for JavaScript/Python/Ruby/PHP. 11/90711/1
authorArtem Naluzhnyy <A.Naluzhnyy@samsung.com>
Mon, 1 Jul 2019 08:52:48 +0000 (10:52 +0200)
committerArtem Naluzhnyy <A.Naluzhnyy@samsung.com>
Mon, 1 Jul 2019 08:52:48 +0000 (10:52 +0200)
Two JJB project parameters have been introduced:
* 'coverity-search-paths' - space separated list of paths that contain
source code to analyse;
* 'coverity-search-exclude-regexs' - space separated list of file name
regexps to exclude from analysis.

Example:

  project:
    name: 'sdc-coverity'
    jobs:
      - onap-gerrit-maven-coverity
    ...
    coverity-search-paths: 'catalog-ui/src/ openecomp-ui/src/ dox-sequence-diagram-ui/src'
    coverity-search-exclude-regexs: '/node_modules/'

Issue-ID: CIMAN-260
Signed-off-by: Artem Naluzhnyy <A.Naluzhnyy@samsung.com>
Change-Id: I8050a75a731c893ec2173f66d2e881fcc0877ed0

jjb/ci-management/ci-management-coverity.yaml
shell/maven-coverity.sh

index ba37d57..83bdffc 100644 (file)
     coverity-project-name: ''
     coverity-token: ''
     coverity-user-email: ''
+    coverity-search-paths: ''
+    coverity-search-exclude-regexs: ''
     stream: master
     submodule-recursive: true
     submodule-timeout: 10
     submodule-disable: false
     archive-artifacts: >
       **/*.log
+      **/*-log.txt
       **/hs_err_*.log
       **/target/**/feature.xml
       **/target/failsafe-reports/failsafe-summary.xml
       **/target/surefire-reports/*-output.txt
       **/cov-int/BUILD.metrics.xml
-      **/cov-int/build-log.txt
       **/cov-int/build-timings.txt
       **/cov-int/java-security-da-whitelist.dat
 
@@ -93,6 +95,8 @@
             COVERITY_PROJECT_NAME={coverity-project-name}
             COVERITY_TOKEN={coverity-token}
             COVERITY_USER_EMAIL={coverity-user-email}
+            SEARCH_PATHS={coverity-search-paths}
+            SEARCH_EXCLUDE_REGEXS={coverity-search-exclude-regexs}
       - shell: !include-raw-escape:
           - ../../global-jjb/shell/common-variables.sh
           - ../../shell/maven-coverity.sh
index 17601d4..22a42c2 100644 (file)
@@ -19,6 +19,25 @@ PS4='+['$(readlink -f "$0")' ${FUNCNAME[0]%main}#$LINENO] '
 
 echo '---> maven-coverity.sh'
 
+#-----------------------------------------------------------------------------
+# Process parameters for JS/PHP/Ruby files analysis
+
+FS_CAPTURE_SEARCH_PARAMS=''
+if [ -n "${SEARCH_PATHS:=}" ]; then
+  for SEARCH_PATH in ${SEARCH_PATHS}; do
+    if [ -d "${SEARCH_PATH}" ]; then
+      FS_CAPTURE_SEARCH_PARAMS="${FS_CAPTURE_SEARCH_PARAMS} --fs-capture-search '${SEARCH_PATH}'"
+    else
+      echo "'${SEARCH_PATH}' from \$SEARCH_PATHS is not an existing directory." >&2
+      exit 1
+    fi
+  done
+fi
+
+for EXCLUDE_REGEX in ${SEARCH_EXCLUDE_REGEXS:=}; do
+  FS_CAPTURE_SEARCH_PARAMS="${FS_CAPTURE_SEARCH_PARAMS} --fs-capture-search-exclude-regex '${EXCLUDE_REGEX}'"
+done
+
 #-----------------------------------------------------------------------------
 # Check if we are allowed to submit results to Coverity Scan service
 # and have not exceeded our upload quota limits
@@ -96,8 +115,9 @@ rm 'coverity_tool.tgz'
 
 export MAVEN_OPTS
 
-cov-build \
+eval cov-build \
   --dir 'cov-int' \
+  ${FS_CAPTURE_SEARCH_PARAMS} \
   "${MVN}" clean install \
     --errors \
     --global-settings "${GLOBAL_SETTINGS_FILE}" \