-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run sonarcloud analysis for long lived branches and PRs
- Loading branch information
1 parent
6f4ca55
commit d6e191a
Showing
2 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -xeuo pipefail | ||
|
||
SONAR_PARAMS=( | ||
-k:"${CIRRUS_REPO_NAME}" | ||
-o:"sonarsource" | ||
-d:sonar.host.url="${SONAR_URL}" | ||
-d:sonar.token="${SONAR_TOKEN}" | ||
-d:sonar.analysis.buildNumber="${CI_BUILD_NUMBER}" | ||
-d:sonar.analysis.pipeline="$CIRRUS_BUILD_ID" | ||
-d:sonar.analysis.sha1="${CIRRUS_CHANGE_IN_REPO}" | ||
-d:sonar.cs.vscoveragexml.reportsPaths="${COVERAGE_FILE}" | ||
-d:sonar.scanner.scanAll=false | ||
) | ||
|
||
if [ "$CIRRUS_BRANCH" == "master" ] && [ "$CIRRUS_PR" == "false" ]; then | ||
echo '======= Analyze master branch' | ||
dotnet sonarscanner begin "${SONAR_PARAMS[@]}" | ||
|
||
elif [[ "$CIRRUS_BRANCH" == "branch-"* || "$CIRRUS_BRANCH" == "feature/"* ]] && [ "$CIRRUS_PR" == "false" ]; then | ||
echo '======= Analyze long lived branch' | ||
dotnet sonarscanner begin "${SONAR_PARAMS[@]}" -d:sonar.branch.name="${CIRRUS_BRANCH}" | ||
|
||
elif [ "$CIRRUS_PR" != "false" ]; then | ||
echo '======= Analyze pull request' | ||
dotnet sonarscanner begin "${SONAR_PARAMS[@]}" \ | ||
-d:sonar.pullrequest.key="${CIRRUS_PR}" \ | ||
-d:sonar.pullrequest.branch="${CIRRUS_BRANCH}" \ | ||
-d:sonar.pullrequest.base="${CIRRUS_BASE_BRANCH}" | ||
|
||
else | ||
echo '======= No analysis' | ||
fi |