Static code analysis for ric-plt-utils 86/5086/4
authorAlok Bhatt <alok_bh@hcl.com>
Fri, 13 Nov 2020 22:54:17 +0000 (22:54 +0000)
committerAlok Bhatt <alok_bh@hcl.com>
Thu, 19 Nov 2020 04:34:35 +0000 (04:34 +0000)
This change adds the job to trigger sonar scans on the ric-plt-utils repo.

Issue-Id: 694
Signed-off-by: Alok Bhatt <alok_bh@hcl.com>
Change-Id: Iaaebc0077a3cbaf19e3609505e7a4eea483f5e75

jjb/ric-plt-utils/Dockerfile.build [new file with mode: 0644]
jjb/ric-plt-utils/cmake-sonarqube.sh [new file with mode: 0644]
jjb/ric-plt-utils/ric-plt-utils.yaml

diff --git a/jjb/ric-plt-utils/Dockerfile.build b/jjb/ric-plt-utils/Dockerfile.build
new file mode 100644 (file)
index 0000000..387bef3
--- /dev/null
@@ -0,0 +1,83 @@
+# vi: ts=4 sw=4 noet:\r
+\r
+#==================================================================================\r
+#    Copyright (c) 2020 AT&T Intellectual Property.\r
+#    Copyright (c) 2020 Nokia\r
+#\r
+#   Licensed under the Apache License, Version 2.0 (the "License");\r
+#   you may not use this file except in compliance with the License.\r
+#   You may obtain a copy of the License at\r
+#\r
+#       http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+#   Unless required by applicable law or agreed to in writing, software\r
+#   distributed under the License is distributed on an "AS IS" BASIS,\r
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+#   See the License for the specific language governing permissions and\r
+#   limitations under the License.\r
+#==================================================================================\r
+\r
+# Build the munchkin container assuming that the current working directory is the\r
+# top of the munchkin portion of the shared repo.\r
+\r
+# ---- these are global and must be set before the first from directive\r
+#\r
+# package versions and locations for easier maintenance\r
+ARG RMR_VER=4.1.4\r
+ARG LOG_VER=0.0.4\r
+ARG FRAME_VER=2.2.0\r
+\r
+ARG PROD_URL_BASE=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/\r
+ARG BETA_URL_BASE=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/\r
+\r
+ARG LOG_BASE=${PROD_URL_BASE}\r
+ARG RMR_BASE=${BETA_URL_BASE}\r
+ARG FRAME_BASE=${BETA_URL_BASE}\r
+\r
+\r
+# -----------------------------------------------------------------------------------------------------\r
+FROM ubuntu:18.04\r
+\r
+RUN    apt-get update \\r
+        && apt-get install -y git cmake make g++ wget curl libcurl4-gnutls-dev libcurlpp-dev libcurlpp0\r
+\r
+\r
+# sadly they need to be 'touched' to pull them into each stage\r
+ARG RMR_VER\r
+ARG LOG_VER\r
+ARG FRAME_VER\r
+ARG FRAME_BASE\r
+ARG RMR_BASE\r
+ARG LOG_BASE\r
+\r
+WORKDIR /playpen/down\r
+\r
+RUN    wget --content-disposition ${LOG_BASE}/mdclog_${LOG_VER}-1_amd64.deb/download.deb \\r
+        && wget --content-disposition ${LOG_BASE}/mdclog-dev_${LOG_VER}-1_amd64.deb/download.deb  \\r
+        && wget --content-disposition ${RMR_BASE}/rmr-dev_${RMR_VER}_amd64.deb/download.deb  \\r
+        && wget --content-disposition ${RMR_BASE}/rmr_${RMR_VER}_amd64.deb/download.deb  \\r
+        && wget --content-disposition ${FRAME_BASE}/ricxfcpp_${FRAME_VER}_amd64.deb/download.deb  \\r
+        && wget --content-disposition ${FRAME_BASE}/ricxfcpp-dev_${FRAME_VER}_amd64.deb/download.deb  \\r
+        && dpkg -i *deb\r
+\r
+\r
+\r
+WORKDIR /playpen/build\r
+COPY ./ ./\r
+\r
+# build the utility; installs into /usr/local/bin\r
+#\r
+RUN    rm -fr .build \\r
+        && mkdir .build \\r
+        && cd .build \\r
+        && cmake .. \\r
+        && make install \\r
+        && make test ARGS="-V"\r
+\r
+\r
+\r
+#RUN mkdir /var/mgxapp\r
+#COPY xapp_config.json /var/mgxapp/config.json\r
+\r
+#WORKDIR /playpen\r
+#CMD [ "munchkin", "-c", "/var/mgxapp/config.json" ]
\ No newline at end of file
diff --git a/jjb/ric-plt-utils/cmake-sonarqube.sh b/jjb/ric-plt-utils/cmake-sonarqube.sh
new file mode 100644 (file)
index 0000000..891f1c3
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash\r
+# SPDX-License-Identifier: EPL-1.0\r
+##############################################################################\r
+# Copyright (c) 2020 HCL Technologies and others.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Eclipse Public License v1.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+##############################################################################\r
+echo "---> cmake-sonarqube.sh"\r
+cd mgxapp\r
+docker build -t ric-plt-utils -f Dockerfile.build .\r
+docker create --name  ric-plt-utils ric-plt-utils\r
+docker cp ric-plt-utils:/playpen/build/test/ .\r
+docker rm ric-plt-utils\r
+echo "---> cmake-sonarqube.sh ends"
\ No newline at end of file
index 276db49..3735fc6 100644 (file)
@@ -7,8 +7,104 @@
 
 - project:
     name: ric-plt-utils-info
-    project: ric-plt/utils
+    project: ric-plt-utils
     project-name: ric-plt-utils
     build-node: centos7-builder-1c-1g
     jobs:
       - gerrit-info-yaml-verify
+
+- utils_common: &utils_common
+    name: utils-common
+    # git repo
+    project: ric-plt/utils
+    # jenkins job name prefix
+    project-name: ric-plt-utils
+    # maven settings file has credentials to archive artifacts
+    mvn-settings: ric-plt-utils-settings
+    # test scripts depend on this name
+    build-dir: $WORKSPACE/mgxapp/build
+    # Use ubuntu base for cmake v3
+    # Use docker variant for packagecloud ruby gem
+    build-node: ubuntu1804-docker-4c-4g
+    # pre-build scripts for CMake templates:
+    # install alien package to build RPMS
+    # install RMR per version file in repo
+    pre-build: !include-raw-escape:
+      - ../shell/install-deb-alien.sh
+      - ./cmake-sonarqube.sh
+    # skip install in cmake-build.sh
+    install: false
+
+# verify every commit
+- project:
+    <<: *utils_common
+    name: utils-verify
+    cmake-opts: -DDEV_PKG=1
+    make-opts: package test ARGS=-V
+    jobs:
+      - gerrit-cmake-verify
+    stream:
+      - master:
+          branch: master
+
+# development library - package and publish
+- project:
+    <<: *utils_common
+    name: ric-plt-utils-dev
+    project-name: '{name}'
+    cmake-opts: -DDEV_PKG=1
+    make-opts: package
+    install-prefix: /usr/local
+    jobs:
+      - gerrit-cmake-packagecloud-stage
+    stream:
+      - master:
+          branch: master
+
+# runtime library - package and publish
+- project:
+    <<: *utils_common
+    name: ric-plt-utils-rt
+    project-name: '{name}'
+    cmake-opts: -DDEV_PKG=0
+    make-opts: package
+    install-prefix: /usr/local
+    jobs:
+      - gerrit-cmake-packagecloud-stage
+    stream:
+      - master:
+          branch: master
+
+# promote deb/rpm from staging to release at PackageCloud.io
+- project:
+    <<: *utils_common
+    name: ric-plt-utils-release
+    # release uses sigul which requires centos
+    build-node: centos7-builder-1c-1g
+    jobs:
+      - gerrit-packagecloud-release-verify
+      - gerrit-packagecloud-release-merge
+
+# analyze C code and test coverage
+- project:
+    name: utils-sonarqube
+    <<: *utils_common
+    make-opts: test ARGS=-V
+    sonar-project-file: ""
+    sonar-properties: |
+        sonar.login={sonarcloud_api_token}
+        sonar.projectKey={sonarcloud_project_organization}_{project-name}
+        sonar.projectName={project-name}
+        sonar.organization={sonarcloud_project_organization}
+        sonar.scanner.force-deprecated-java-version=true
+        sonar.build.sourceEncoding=UTF-8
+        sonar.sources=mgxapp/src
+        sonar.cfamily.threads=4
+        sonar.cfamily.cache.enabled=false
+        sonar.cfamily.build-wrapper-output=$WORKSPACE/bw-output
+        sonar.cfamily.gcov.reportsPath=test
+        sonar.c.file.suffixes=-
+        sonar.cpp.file.suffixes=-
+        sonar.objc.file.suffixes=-
+    jobs:
+      - gerrit-cmake-sonarqube