Ray Milkey | 20d2252 | 2017-11-08 10:55:52 -0800 | [diff] [blame] | 1 | #!/bin/bash -ex |
Ray Milkey | cb569c3 | 2017-12-12 13:42:20 -0800 | [diff] [blame] | 2 | |
| 3 | # exit on errors |
| 4 | set -eu -o pipefail |
| 5 | |
Ray Milkey | 20d2252 | 2017-11-08 10:55:52 -0800 | [diff] [blame] | 6 | ONOS_ROOT=`pwd` |
| 7 | . tools/build/envDefaults |
| 8 | |
Ray Milkey | 10b9647 | 2018-11-21 13:31:06 -0800 | [diff] [blame] | 9 | PATH=$PATH:/home/jenkins/bin |
| 10 | |
Ray Milkey | faa66c9 | 2017-11-08 12:58:43 -0800 | [diff] [blame] | 11 | # download and install Sonar scanner |
Ray Milkey | 7d9c036 | 2019-01-25 13:06:15 -0800 | [diff] [blame] | 12 | SONAR_SCANNER_VERSION=3.3.0.1492 |
Ray Milkey | 96246bc | 2020-01-24 10:21:29 -0800 | [diff] [blame] | 13 | curl -L -o /tmp/sonar-scanner-cli.zip -X GET https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/$SONAR_SCANNER_VERSION/sonar-scanner-cli-$SONAR_SCANNER_VERSION.zip |
Ray Milkey | 20d2252 | 2017-11-08 10:55:52 -0800 | [diff] [blame] | 14 | unzip /tmp/sonar-scanner-cli.zip |
Ray Milkey | faa66c9 | 2017-11-08 12:58:43 -0800 | [diff] [blame] | 15 | |
| 16 | # Configure ONOS specific properties |
Andrew Grimberg | 6ecb1b1 | 2017-11-16 14:42:39 -0800 | [diff] [blame] | 17 | echo "sonar.host.url=https://sonar.onosproject.org" >>sonar-scanner-$SONAR_SCANNER_VERSION/conf/sonar-scanner.properties |
Ray Milkey | 20d2252 | 2017-11-08 10:55:52 -0800 | [diff] [blame] | 18 | |
Ray Milkey | faa66c9 | 2017-11-08 12:58:43 -0800 | [diff] [blame] | 19 | # Generate coverage data |
| 20 | tools/build/onos-prepare-sonar |
| 21 | |
| 22 | # Upload coverage to Sonar |
Ray Milkey | 7d9c036 | 2019-01-25 13:06:15 -0800 | [diff] [blame] | 23 | cd bazel-genfiles/sonar-project && $ONOS_ROOT/sonar-scanner-$SONAR_SCANNER_VERSION/bin/sonar-scanner |