From b9ed4b7dd6c2342bc87209d415b840d65ea5ccf0 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Thu, 11 Aug 2022 17:14:16 +0200 Subject: ci: call docker-compose in sonarcloud trigger Ref: HICN-739 Change-Id: I33c4948f6f7a1a27a30051da4a1bdbfc6de90951 Signed-off-by: Mauro Sardara --- scripts/build-sonar.sh | 39 ++++++++++++++------------------------- scripts/docker-compose-sonar.yml | 2 +- scripts/run-sonar.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 26 deletions(-) mode change 100755 => 100644 scripts/build-sonar.sh create mode 100755 scripts/run-sonar.sh diff --git a/scripts/build-sonar.sh b/scripts/build-sonar.sh old mode 100755 new mode 100644 index ac1f878b4..f5f72629f --- a/scripts/build-sonar.sh +++ b/scripts/build-sonar.sh @@ -1,27 +1,16 @@ -#!/bin/bash - -# SONAR_HOST_URL=https://sonarcloud.io -# PROJECT_KEY=fdio_hicn -# PROJECT_ORGANIZATION=fdio - -export SONAR_TOKEN=$API_TOKEN -export SONAR_SCANNER_VERSION=4.7.0.2747 -export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux -curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip -unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ -export PATH=$SONAR_SCANNER_HOME/bin:$PATH -export SONAR_SCANNER_OPTS="-server" -curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip -unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ -export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH +# Copyright (c) 2017-2022 Cisco and/or its affiliates. +# 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. -cd /workspace - -$HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make build +#!/bin/bash -$SONAR_SCANNER_HOME/bin/sonar-scanner \ --Dsonar.organization=$PROJECT_ORGANIZATION \ --Dsonar.projectKey=$PROJECT_KEY \ --Dsonar.sources=/workspace \ --Dsonar.cfamily.build-wrapper-output=bw-output \ --Dsonar.host.url=$SONAR_HOST_URL \ No newline at end of file +docker-compose -f docker-compose-sonar.yaml up diff --git a/scripts/docker-compose-sonar.yml b/scripts/docker-compose-sonar.yml index 310107241..52fceded4 100644 --- a/scripts/docker-compose-sonar.yml +++ b/scripts/docker-compose-sonar.yml @@ -10,4 +10,4 @@ services: - ..:/workspace command: - | - /workspace/scripts/build-sonar.sh \ No newline at end of file + /workspace/scripts/run-sonar.sh \ No newline at end of file diff --git a/scripts/run-sonar.sh b/scripts/run-sonar.sh new file mode 100755 index 000000000..b1b280518 --- /dev/null +++ b/scripts/run-sonar.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# SONAR_HOST_URL=https://sonarcloud.io +# PROJECT_KEY=fdio_hicn +# PROJECT_ORGANIZATION=fdio + +export SONAR_TOKEN=$API_TOKEN +export SONAR_SCANNER_VERSION=4.7.0.2747 +export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux +curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip +unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ +export PATH=$SONAR_SCANNER_HOME/bin:$PATH +export SONAR_SCANNER_OPTS="-server" +curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip +unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ +export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH + +cd /workspace + +$HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make build + +$SONAR_SCANNER_HOME/bin/sonar-scanner \ +-Dsonar.organization=$PROJECT_ORGANIZATION \ +-Dsonar.projectKey=$PROJECT_KEY \ +-Dsonar.sources=/workspace \ +-Dsonar.cfamily.build-wrapper-output=bw-output \ +-Dsonar.host.url=$SONAR_HOST_URL -- cgit 1.2.3-korg