Skip to content

Commit

Permalink
Fix request to sonar (#8)
Browse files Browse the repository at this point in the history
* fix: url request sonar api
  • Loading branch information
sentoz authored Jan 31, 2024
1 parent 9c13bde commit e0970d8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 21 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All noticeable changes to this project will be documented in this file.
The format is based on [changelog][keepachangelog], and this project adheres
to [semantic versioning][semver].

## [0.2.1][] `2023-12-27`

### Fixed

* Request coverage and project with api sonarqube

## [0.2.0][] `2023-12-27`

### Added
Expand Down Expand Up @@ -41,6 +47,7 @@ to [semantic versioning][semver].

<!-- Tags -->

[0.2.1]: https://github.com/sentoz/multi-sonarqube-scanner-cli/tree/0.2.2
[0.2.0]: https://github.com/sentoz/multi-sonarqube-scanner-cli/tree/0.2.0
[0.1.2]: https://github.com/sentoz/multi-sonarqube-scanner-cli/tree/0.1.2
[0.1.1]: https://github.com/sentoz/multi-sonarqube-scanner-cli/tree/0.1.1
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The current cache of plugins will be packed into the image in the directory

### Standard Image

`sentoz/multi-sonarqube-scanner-cli:0.2.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1`

This image allows you to scan projects implemented in languages:

Expand All @@ -107,19 +107,19 @@ This image allows you to scan projects implemented in languages:

### Images for analyzing .NET projects

`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-3.1`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-5.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-6.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-7.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-8.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-3.1`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-5.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-6.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-7.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-8.0`

Each image is built on the latest stable version of `.Net`, includes
`dotnet sonarscanner` and `reportgenerator`.

### Image for analyzing Gradle projects

`sentoz/multi-sonarqube-scanner-cli:0.2.0-gradle-8.1.1`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-gradle-7.3.3`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-gradle-8.1.1`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-gradle-7.3.3`

The gradle binaries of the latest stable version are packed into the image.

Expand Down
16 changes: 8 additions & 8 deletions README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

### Стандартный образ

`sentoz/multi-sonarqube-scanner-cli:0.2.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1`

Данный образ позволяет сканировать проекты реализованные на языках:

Expand All @@ -107,19 +107,19 @@

### Образы для анализа .NET проектов

`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-3.1`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-5.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-6.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-7.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-dotnet-8.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-3.1`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-5.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-6.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-7.0`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-dotnet-8.0`

Каждый образ собирается на последней стабильной версии `.Net`, включает в себя
`dotnet sonarscanner` и `reportgenerator`.

### Образ для анализа Gradle проектов

`sentoz/multi-sonarqube-scanner-cli:0.2.0-gradle-8.1.1`
`sentoz/multi-sonarqube-scanner-cli:0.2.0-gradle-7.3.3`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-gradle-8.1.1`
`sentoz/multi-sonarqube-scanner-cli:0.2.1-gradle-7.3.3`

В образ пакуются бинарные файлы gradle последней стабильной версии.

Expand Down
18 changes: 14 additions & 4 deletions scripts/get_sonar_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ sq-api() {
"${SONARQUBE_URL:-}/api/$path" "${@}"
}

# Encode url symbols
urlencode() {
local LC_COLLATE=C length="${#1}"
for ((i = 0; i < length; i++)); do
local c="${1:$i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
}

coverage=$(
sq-api measures/component \
-d "component=$SONARQUBE_PROJECT_KEY" \
-d "metricKeys=coverage" \
-d "${coverage_reference:-}" |
sq-api \
"measures/component?component=$(urlencode "$SONARQUBE_PROJECT_KEY")&metricKeys=coverage&${coverage_reference:-}" |
jq -er '.component.measures[] | select(.metric == "coverage") | .value' || :
)

Expand Down
5 changes: 4 additions & 1 deletion scripts/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ version="${REF_NAME:-MR-${MERGE_REQUEST_ID:-0}}"
# Check default branch name
# Get branches list data
sq_branches="$(
sq-api project_branches/list -d "project=$SONARQUBE_PROJECT_KEY" ||
sq-api project_branches/list?project="$SONARQUBE_PROJECT_KEY" ||
echo '{}'
)"

Expand Down Expand Up @@ -56,6 +56,9 @@ fi
'branch, only then will you be able to parse merge requests, tags,' \
"and other branches. $SUPPORT_CONTACTS"

# TODO migrate to a new method that allows you to change the default
# TODO branch. think through the logic if the default branch is new.

# Get name of current default branch in SQ
sq_curent_default_branch="$(
jq -er '.branches[] | select(.isMain==true) | .name' <<<"$sq_branches" \
Expand Down

0 comments on commit e0970d8

Please sign in to comment.