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 -O /tmp/sonar-scan.zip \
25 "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip"
27 sudo mv sonar-scanner-* /opt/sonar-scanner
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 /opt/build-wrapper/build-wrapper-linux-x86-64 --out-dir "$WORKSPACE/bw-output" \
43 /opt/sonar-scanner/bin/sonar-scanner \
44 -Dsonar.projectKey=${PROJECT_KEY} \
45 -Dsonar.organization=${PROJECT_ORGANIZATION} \
47 -Dsonar.cfamily.build-wrapper-output="$WORKSPACE/bw-output" \
48 -Dsonar.host.url=${SONAR_HOST_URL} \
49 -Dsonar.login=${API_TOKEN}