From a99e32fc13e9e7e3c407cc80432a8da236df83a5 Mon Sep 17 00:00:00 2001 From: Nicolas Oliver Date: Tue, 15 Aug 2017 11:43:46 -0300 Subject: [PATCH] sonar: remove sonar-scan from allow_failures Signed-off-by: Nicolas Oliver --- .travis.yml | 1 - scripts/sonar-scan.sh | 24 +++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 74547323..f1e8b717 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ before_install: jobs: fast_finish: true allow_failures: - - env: TARGET=sonar-scan - env: TARGET=ipk include: - &run-with-clang diff --git a/scripts/sonar-scan.sh b/scripts/sonar-scan.sh index c869cf70..6ff10ef1 100755 --- a/scripts/sonar-scan.sh +++ b/scripts/sonar-scan.sh @@ -23,10 +23,24 @@ # - UPM_SRC_DIR - path to upm's git clone in the Docker container. # Check required environment variables and exit if they are not set -UPM_SRC_DIR=${UPM_SRC_DIR:?value not provided} -SONAR_PROJ_KEY=${SONAR_PROJ_KEY:?value not provided} -SONAR_ORG=${SONAR_ORG:?value not provided} -SONAR_TOKEN=${SONAR_TOKEN:?value not provided} +function check_environment { + VAR_NAME=$1 + VAR_VALUE=$2 + # Check required parameters + VAR_NAME=${VAR_NAME:?value not provided} + # Chek if variable is set + if [ -z "${VAR_VALUE}" ]; then + echo "Required environment variable ${VAR_NAME} is not defined. Skipping Execution..." + exit 0; + else + echo "Required environment variable ${VAR_NAME} is set." + fi +} + +check_environment "UPM_SRC_DIR" ${UPM_SRC_DIR} +check_environment "SONAR_PROJ_KEY" ${SONAR_PROJ_KEY} +check_environment "SONAR_ORG" ${SONAR_ORG} +check_environment "SONAR_TOKEN" ${SONAR_TOKEN} bw_output_path="${UPM_SRC_DIR}/build/bw-output" @@ -57,7 +71,7 @@ if [ "${TRAVIS_BRANCH}" == "master" -a "${TRAVIS_PULL_REQUEST}" == "false" ]; th sonar_cmd="${sonar_cmd_base}" elif [ "${TRAVIS_PULL_REQUEST}" != "false" -a "${TRAVIS_PULL_REQUEST_SLUG}" == "${TRAVIS_REPO_SLUG}" ]; then # Internal PR - do a preview scan with report to the PR - ${GITHUB_TOKEN:?value not provided} + check_environment "GITHUB_TOKEN" ${GITHUB_TOKEN} echo "Performing internal pull request scan" sonar_cmd="${sonar_cmd_base} \