Skip to content

Commit a215ca4

Browse files
authored
use non-admin token for sonarQube (#8731)
1 parent 9027488 commit a215ca4

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

backend/plugins/sonarqube/api/blueprint_v200.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ func GetApiProject(
131131
}
132132
query := url.Values{}
133133
query.Set("q", projectKey)
134-
res, err := apiClient.Get("projects/search", query, nil)
134+
// Use components/search_projects for consistency and normal-token (Browse) support.
135+
res, err := apiClient.Get("components/search_projects", query, nil)
135136
if err != nil {
136137
return nil, err
137138
}

backend/plugins/sonarqube/api/remote_api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ func querySonarqubeProjects(
4848
if page.Page == 0 {
4949
page.Page = 1
5050
}
51-
res, err := apiClient.Get("projects/search", url.Values{
51+
// Use components/search_projects so non-admin (Browse) tokens can list projects.
52+
res, err := apiClient.Get("components/search_projects", url.Values{
5253
"p": {fmt.Sprintf("%v", page.Page)},
5354
"ps": {fmt.Sprintf("%v", page.PageSize)},
5455
"q": {keyword},

config-ui/src/plugins/register/sonarqube/config.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ export const SonarQubeConfig: IPluginConfig = {
5555
setErrors={setErrors}
5656
/>
5757
),
58-
'token',
58+
{
59+
key: 'token',
60+
subLabel:
61+
'A token with Browse permission on the projects you want is sufficient for listing projects and collecting issues, hotspots, and file metrics. Listing Accounts (users) may require a system admin token on some SonarQube instances.',
62+
},
5963
'proxy',
6064
{
6165
key: 'rateLimitPerHour',

0 commit comments

Comments
 (0)