2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
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 echo "---> cmake-sonar.sh"
13 build_dir="${BUILD_DIR:-$WORKSPACE/target}"
14 cmake_opts="${CMAKE_OPTS:-}"
15 make_opts="${MAKE_OPTS:-}"
24 wget -q -O /tmp/sonar-scan.zip \
25 "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip"
26 unzip -q sonar-scan.zip
27 sudo mv sonar-scanner-* /opt/sonar-scanner
29 wget -q -O /tmp/bw.zip \
30 "https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip"
32 sudo mv build-wrapper-* /opt/build-wrapper
35 cd "$build_dir" || exit 1
36 # $cmake_opts needs to wordsplit to pass options.
37 # shellcheck disable=SC2086
38 eval cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $cmake_opts ..
40 # $make_opts may be empty.
41 # shellcheck disable=SC2086
42 /opt/build-wrapper/build-wrapper-linux-x86-64 --out-dir "$WORKSPACE/bw-output" \
45 /opt/sonar-scanner/bin/sonar-scanner \
46 -Dsonar.projectKey="${PROJECT_KEY}" \
47 -Dsonar.organization="${PROJECT_ORGANIZATION}" \
49 -Dsonar.cfamily.build-wrapper-output="$WORKSPACE/bw-output" \
50 -Dsonar.host.url="${SONAR_HOST_URL}" \
51 -Dsonar.login="${API_TOKEN}"