Chore: Upgrade Jenkins-job-builder to 6.3.0
[releng/global-jjb.git] / shell / sonar-cli.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2022 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 # Non-Maven Sonar CLI
12 echo "---> sonar-cli.sh"
13
14 SCANNER_BIN="sonar-scanner-${SONAR_SCANNER_VERSION}-linux"
15 export SONAR_SCANNER_HOME="${WORKSPACE}/.sonar/${SCANNER_BIN}"
16 export PATH="${SONAR_SCANNER_HOME}/bin:${PATH}"
17
18 curl --create-dirs -sSLo "${WORKSPACE}"/.sonar/sonar-scanner.zip \
19 https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/\
20 sonar-scanner-cli-"${SONAR_SCANNER_VERSION}"-linux.zip
21 unzip -o "${WORKSPACE}"/.sonar/sonar-scanner.zip -d "${WORKSPACE}"/.sonar/
22
23 echo "Running sonar-scanner"
24 sonar-scanner \
25     -Dsonar.organization="${SONARCLOUD_PROJECT_ORGANIZATION}" \
26     -Dsonar.projectKey="${SONARCLOUD_PROJECT_ORGANIZATION}_${SONARCLOUD_PROJECT_KEY}" \
27     -Dsonar.sources=. \
28     -Dsonar.host.url=https://sonarcloud.io