-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsonar-scan.sh
executable file
·28 lines (22 loc) · 1.01 KB
/
sonar-scan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
# Print a command before actually executing it
set -x
# Break the script if one of the command fails (returns non-zero status code)
set -e
# $SONAR_TOKEN must be defined
# $GitVersion_FullSemVer can be used to specify the current version (see GitVersion)
VERSION=""
if [ -n "$GitVersion_FullSemVer" ]; then
VERSION="/v:"$GitVersion_FullSemVer
fi
dotnet build-server shutdown
dotnet sonarscanner begin \
/d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$SONAR_TOKEN" \
/o:"alexeyshockov" /k:"alexeyshockov_LocalPost" $VERSION \
/d:sonar.dotnet.excludeTestProjects=true \
/d:sonar.cs.opencover.reportsPaths="tests/*/TestResults/*/coverage.opencover.xml" \
/d:sonar.cs.vstest.reportsPaths="tests/*/TestResults/*.trx"
# See "Importing .NET reports" here: https://docs.sonarqube.org/latest/analysis/coverage/
dotnet build
dotnet test --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings --logger=trx
dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN"